//直播间脚本
function onAsToJs(para) {
    $(window).trigger("onAsToJs", para);//抛出事件
}
function onJsToAs(para) {
    $('#J_VideoPlayerSwf')[0].onJsToAs(para);//视频Swf
    // $('#J_StreamerEffectSwf')[0].onJsToAs(para);//流光Swf
    // $('#J_GiftGroupEffectSwf')[0].onJsToAs(para);//礼物成组效果Swf
}
String.prototype.replaceAll = function (s1, s2) {
    return this.split(s1).join(s2);
}
$(function () {
    var Device = function(){
        var agent = navigator.userAgent.toLowerCase();
        var parseVersion = function(label){
            var exp = new RegExp(label+'/([^\\s\\_\\-]+)');
            label = (agent.match(exp)||[])[1];
            return label ? label.replace(/(?!^\d+\.)(\b\d+)./g, '$1') : false
        };
        var result = {};
        if(/windows/.test(agent)) result.os = "windows";
        if(/linux/.test(agent)) result.os = "linux";
        if(/iphone|ipod|ipad|ios/.test(agent)) result.os = "ios";
        result.android = /android/.test(agent); //是否安卓
        result.mobile = /mobile/.test(agent); //是否移动设备
        result.weixin = parseVersion('micromessenger');//获取微信版本，不在微信WebWiew则返回fa
        result.myapp = parseVersion('myapp');//获取你的App版本，不在App WebWiew则返回falase。记得把myapp改成你的app特殊标识
        result.agent = agent;
        return result;
    };
    var Log = {
        Out: function (label, str) {
            var url = String(window.document.location.href);
            if (url.indexOf('http://www.quanminxiu.tv/') != -1 && url.indexOf('?debug') == -1) {
                return;
            }
            if (str) {
                console.log(label, str);
                return;
            }
            console.log(label);
        }
    };
    var _ThisPage = {
        Flash: {
            Data: {
                isInit: false, //Flash是否已初始化
                isPlay: false, //Join触发,Flash还未初始化，成功时，此值为Falsh
                isPlayData: {},//临时存储的值
                Event: []//调用函数 事件
            },
            AsToJs: function (event, para) {
                Log.Out(para.type, para);
                switch (para.type) {
                    case "flash_init":
                        //Flash初始化
                        Log.Out("Flash初始化");
                        _ThisPage.Flash.Init();
                        break;
                    case "EffectSwitch":
                        //Flash效果开关 按钮事件
                        _ThisPage.Page.Gift.Data.isEffectOn = para.isOpen;
                        break;
                    case "StartLive":
                        //Flash开始直播 按钮事件
                        $.CommonMainRoom.SocketEmit.Live();
                        break;
                    case "EndLive":
                        //Flash结束直播 按钮事件
                        $.CommonMainRoom.SocketEmit.LiveEnd();
                        break;
                    case "change_anchor":
                        //换一换 艺人
                        break;
                    case "login":
                        //登录
                        if (para.act == "qq_btn") {
                            window.open(_VirtualPath.Main + 'oauth/qqconnect.tologin', "TencentLogin", "width=450,height=320,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,location=1");
                        } else if (para.act == "weibo_btn") {
                            window.open(_VirtualPath.Main + 'oauth/weibo.tologin', "TencentLogin", "width=450,height=320,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,location=1");
                        } else if (para.act == "xiyou_btn") {
                            $.CommonMain.Login('In');
                        }
                        break;
                    case "network_speed":
                        //网络速度
                        Log.Out("newwork_speed = ", para);
                        break;
                    case "streamer_init":
                        //初始化流光
                        break;
                    case "PoundEgg_CloseWindow":
                        //关闭窗口 砸蛋
                        $('#J_GoldEgg_DIV').hide();
                        break;
                    case "PoundEgg_SendData":
                        Log.Out("发送数据 砸蛋", para);
                        if (!$.CommonMain.LoginCheck()) return;
                        //发送数据 砸蛋
                        $.CommonMainRoom.SocketEmit.PoundEgg({
                            PoundEgg_ID:parseInt(para.hammerId)*1000
                        });
                        break;
                }
            },
            //初始化
            Init: function () {
                _ThisPage.Flash.Data.isInit = true;
                Log.Out("FlashInit");
                onJsToAs({type: 'BarrageAlign', data: 1});//弹幕向下对齐
                if (_ThisPage.Flash.Data.Event.length > 0) {
                    for (var i = 0; i < _ThisPage.Flash.Data.Event.length; i++) {
                        var event = _ThisPage.Flash.Data.Event[i];
                        _ThisPage.Flash[event.type](event.data);
                        Log.Out("FlashInit >>> ", [event]);
                    }
                    _ThisPage.Flash.Data.Event = [];
                }
                _Socket.Init();
            },
            //进入房后 通知flash
            JoinRoom: function (data) {
                if (_ThisPage.Flash.Data.isInit) {
                    var userType = (_StateData.IsLogin) ? ($.CommonMainRoom.RoomUserInfo.RoomAnchor ? 1 : 2) : 3;//1艺人2注册用户3游客
                    //让Flash显示 艺人或用户 界面
                    onJsToAs({
                        type: "IsAnchor",
                        userType: userType,
                        isMobile: $.CommonMainRoom.RoomInfo.Live_IsMobile,
                        anchorCoverPic: $.Common.ImageBind.UserCover.fnURL($.CommonMainRoom.RoomInfo.RoomID, "442.442")
                    });

                    if (!$.CommonMainRoom.RoomInfo.Live_IsMobile) {//不是手机直播,设置为 2大比例(有裁切)
                        onJsToAs({type: "ShowType", data: 2});
                        Log.Out('VideoShowType', 2);
                    }

                    if (data.Live) {
                        _ThisPage.Flash.PlayVideo(data);//进房成功后 是否正在直播
                    } else {
                        _ThisPage.Flash.EndLive();//有可能断线后，重联，将直播状态，断开。
                    }
                } else {
                    Log.Out("Join之前", data);
                    _ThisPage.Flash.Data.Event.push({type: "JoinRoom", data: data});
                }
            },
            //播放视频
            PlayVideo: function (data) {
                if (!this.Data.isInit) return;
                if (_ThisPage.Flash.Data.isInit) {
                    // onJsToAs({type: "PlayVideo", rtmpUrl: data.Live_URL});
                    onJsToAs({type: "ShowType", data: (data.Live_IsMobile) ? 1 : 2});
                    onJsToAs({
                        type: "PlayVideo",
                        rtmpUrl: data.Live_URL,
                        isMobile: data.Live_IsMobile,
                        anchorCoverPic: $.Common.ImageBind.UserCover.fnURL($.CommonMainRoom.RoomInfo.RoomID, "442.442")
                    });
                } else {
                    _ThisPage.Flash.Data.isPlay = true;
                    _ThisPage.Flash.Data.isPlayData = data;
                }
            },
            //发布视频
            PublishVideo: function (data) {
                if (!this.Data.isInit) return;
                onJsToAs({type: "PublishVideo", rtmpUrl: data.Live_PUSH});
            },
            //结束直播
            EndLive: function () {
                if (!this.Data.isInit) return;
                onJsToAs({type: "EndLive"});
            },
            //进场座骑
            EnterSceneMountEffect: function (data) {
                Log.Out("JSFlash座骑", data);
                onJsToAs({type: "EnterSceneMountEffect", data: data});
            },
            //大礼物效果
            RunwayFollowUpEffect:function(data){
                onJsToAs({type: "RunwayFollowUpEffect", data: data});
            }
        },
        Page: {
            //页面初始化就执行
            Init: function () {
                if(Device().mobile){
                    //是移动设备
                    window.document.location = "/room/"+_PageData.RoomID+"/m";
                    return;
                }
                //页面自适应
                _ThisPage.Page.ReSize.Init();
                _ThisPage.Page.WinResize();
                //监听Flash传回到页面上的事件
                $(window).off("onAsToJs");
                $(window).on("onAsToJs", _ThisPage.Flash.AsToJs);
                //加载昵称列表
                _ThisPage.Page.RobotManage.LoadNicknameFile(_VirtualPath.Static + "main/js/room.userlist.nickname.txt");
                //左侧导航 显示登录按钮 或 自己信息
                if (_StateData.IsLogin) {
                    $("#J_Panel_Userinfo").show();
                    $("#J_SidebarCollapseMemberCover").show();
                    $("#J_Panel_Login").hide();
                    $("#J_SideBarNavMenu .mod-nav-item").last().remove();
                    $("#J_MemberCollapseLoginForm").hide();
                } else {
                    $("#J_Panel_Userinfo").hide();
                    $("#J_SidebarCollapseMemberCover").hide();
                    $("#J_Panel_Login").show();
                    $("#J_MemberCollapseLoginForm").show();
                }
                //排行榜初始化
                _ThisPage.Page.Ranking.Init();
                //用户信息面板(操作功能)初始化
                _ThisPage.Page.CommonUitls.InitUserInfoPanel();
            },
            //进房成功
            JoinComplete: function (data) {
                //星星初始化
                _ThisPage.Page.PomeloUtil.Init(data.RoomUserInfo);
                //初始化分享数据
                _ThisPage.Page.Share.Init();
                //聊天功能初始化
                _ThisPage.Page.Chat.Init(data);
                //房间初始化
                _ThisPage.Page.Room.Init(data);
                //初始化自己用户卡片
                _ThisPage.Page.Self.Init(data);
                //艺人相关初始化
                _ThisPage.Page.Anchor.Init(data);
                //礼物功能初始化
                _ThisPage.Page.Gift.Init(data);
                //头条
                _ThisPage.Page.GiftHeadline.Init(data);
                //守护功能初始化
                _ThisPage.Page.Guardian.Init(data);
                //在线列表
                _ThisPage.Page.UserList.Init(data);
                //飞屏喇叭初始化
                _ThisPage.Page.FlyScreen.Init(data);
                _ThisPage.Page.Horn.Init(data);
                //视频区初始化
                _ThisPage.Page.Video.Init(data);
                //冻结功能
                _ThisPage.Page.CommonUitls.FrozenRoom.Init(data);
                //任务列表
                _ThisPage.Page.TaskList.Init();
                //测试升级 提示
                // _ThisPage.Page.UserLevelUpgrade.Test.Init();
                //跑道初始化
                _ThisPage.Page.Runway.Init();
                //游戏功能
                _ThisPage.Page.Game.Init();
                //用户举报
                _ThisPage.Page.Report.Init();
            },
            /**
             * 公共数据
             */
            CommonData: {
                /**
                 * 获取一个范围的随机数
                 * @param min
                 * @param max
                 * @returns {*}
                 * @constructor
                 */
                GetRandom:function(min, max){
                    return min + Math.floor( Math.random() * (max-min) );
                }
            },
            /**
             * 公共方法
             */
            CommonUitls: {
                //获取用户头像
                GetUserHand: function (User_ID, Size) {
                    Size = (Size) ? Size : "54.54";
                    return $.Common.ImageBind.UserAvatar.fnURL(User_ID, Size);
                },
                //获取艺人头像
                GetAvatarHand: function (User_ID, Size) {
                    Size = (Size) ? Size : "80.80";
                    return $.Common.ImageBind.UserCover.fnURL(User_ID, Size);
                },
                ////////////////////////////Start 用户菜单//////////////////////////////
                //用户信息面板(操作功能)初始化
                InitUserInfoPanel: function () {
                    //弹出用户卡片
                    $("#J_Chatlistinfo,#J_ChatlistinfoPrivate").off('click');
                    $("#J_Chatlistinfo,#J_ChatlistinfoPrivate").on('click', '[data-uid]', function (event) {
                        if (!$.CommonMain.LoginCheck()) {
                            return;
                        }
                        var data = $(this).data('userdata');

                        //不能对自己或游客操作
                        if (!data || data.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID || data.Guest) {
                            return;
                        }
                        var _left = $(this).offset().left - (218 / 2) + $(this).width() / 2;
                        if ($(window).width() - _left - 218 < 0) {
                            _left = $(window).width() - 218;
                        }
                        var _top = $(this).offset().top + $(this).height() + 8;
                        $("#J_UserCardPop").data('userinfo', data);
                        _ThisPage.Page.CommonUitls.CreateUserInfoMiniCard(data)
                        $("#J_UserCardPop").css({
                            left: _left,
                            top: _top
                        }).fadeIn();
                    });

                    //关闭用户卡片
                    $("#J_UserCardPop").off('mouseleave');
                    $("#J_UserCardPop").on('mouseleave', function (event) {
                        $("#J_UserCardPop").fadeOut(200);
                    });

                    //赠送 to ...
                    $("#J_UserCardPop").off('click', 'a[data-type=1]');
                    $("#J_UserCardPop").on('click', 'a[data-type=1]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        Log.Out("菜单 赠送礼物", UserInfo);
                        _ThisPage.Page.Gift.AddGiftReceiveUserList(UserInfo);
                    });

                    //关注 to ...
                    $("#J_UserCardPop").off('click', 'a[data-type=3]');
                    $("#J_UserCardPop").on('click', 'a[data-type=3]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        _ThisPage.Page.Room.Common.Attention(UserInfo.User_ID, UserInfo.NickName);
                        Log.Out("菜单 关注对象", UserInfo);
                    });

                    //踢人
                    $("#J_UserCardPop").off('click', 'a[data-type=2]');
                    $("#J_UserCardPop").on('click', 'a[data-type=2]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 2;//4 取消
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("踢出房间", UserInfo);
                    });
                    $("#J_UserCardPop").off('click', 'a[data-type=21]');
                    $("#J_UserCardPop").on('click', 'a[data-type=21]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 4;
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("恢复进房", UserInfo);
                    });

                    //禁言
                    $("#J_UserCardPop").off('click', 'a[data-type=4]');
                    $("#J_UserCardPop").on('click', 'a[data-type=4]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 1;
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("设置禁言", UserInfo);
                    });
                    $("#J_UserCardPop").off('click', 'a[data-type=41]');
                    $("#J_UserCardPop").on('click', 'a[data-type=41]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 3;
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("解除禁言", UserInfo);
                    });

                    //提升场控
                    $("#J_UserCardPop").off('click', 'a[data-type=5]');
                    $("#J_UserCardPop").on('click', 'a[data-type=5]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = true;
                        $.CommonMainRoom.SocketEmit.AdminSet(UserInfo.User_ID, type);
                        Log.Out("提升场控", UserInfo);
                    });
                    $("#J_UserCardPop").off('click', 'a[data-type=51]');
                    $("#J_UserCardPop").on('click', 'a[data-type=51]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = false;
                        $.CommonMainRoom.SocketEmit.AdminSet(UserInfo.User_ID, type);
                        Log.Out("撤销场控", UserInfo);
                    });

                    //对Ta说
                    $("#J_UserCardPop").off('click', 'a[data-type=6]');
                    $("#J_UserCardPop").on('click', 'a[data-type=6]', function (event) {
                        _ThisPage.Page.Chat.CommonUtils.CancelHorn.All();
                        _ThisPage.Page.Chat.ChatSelectTab(0);
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        _ThisPage.Page.Chat.Data.ChatUser.id = UserInfo.User_ID;
                        _ThisPage.Page.Chat.Data.ChatUser.Private = false;
                        _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = true;
                        _ThisPage.Page.Chat.Data.ChatUser.Receiver = UserInfo;

                        $("#J_InputTextWord").attr("placeholder", "@ 对 " + UserInfo.NickName + " 说");
                        $('#J_PrivateCancel').show();
                        _ThisPage.Page.CommonUitls.PrivateCancel();
                    });
                    //私聊Ta
                    $("#J_UserCardPop").off('click', 'a[data-type=7]');
                    $("#J_UserCardPop").on('click', 'a[data-type=7]', function (event) {
                        _ThisPage.Page.Chat.CommonUtils.CancelHorn.All();
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        _ThisPage.Page.Chat.Data.ChatUser.id = UserInfo.User_ID;
                        _ThisPage.Page.Chat.Data.ChatUser.Private = true;
                        _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = true;
                        _ThisPage.Page.Chat.Data.ChatUser.Receiver = UserInfo;
                        //这里要 做判断权限 是否可以私聊
                        _ThisPage.Page.Chat.ChatSelectTab(1);
                        $("#J_InputTextWord").attr("placeholder", "@ 对 " + UserInfo.NickName + " 悄悄说");
                        $('#J_PrivateCancel').show();
                        _ThisPage.Page.CommonUitls.PrivateCancel();
                    });
                },
                //取消私聊，对Ta说
                PrivateCancel: function () {
                    $("#J_PrivateCancel").off("click");
                    $("#J_PrivateCancel").on("click", function () {
                        _ThisPage.Page.Chat.ChatSelectTab(0);
                        _ThisPage.Page.Chat.Data.ChatUser.Private = false;
                        _ThisPage.Page.Chat.Data.ChatUser.Receiver = null;
                        $("#J_PrivateCancel").hide();
                        $("#J_InputTextWord").attr("placeholder", "双手打字，以示清白～");
                    });
                },
                //创建资料卡
                CreateUserInfoMiniCard: function (data) {
                    if (data.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID || data.Guest) return; //该菜单是 自己 或 游客 就显示此菜单

                    var _Path = data.RoomAnchor ? "anchor/" : "user/";
                    var _Level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                    var CardInfo = "";
                    //弹出信息卡
                    CardInfo += '<div class="card-content">';
                    CardInfo += '<ul class="card-authinfo">';

                    if (data.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID) { //该菜单 用户 => 艺人
                        CardInfo += '<li><a href="javascript:;" class="auth-song" data-type="1">送礼物</a></li>';
                        CardInfo += '<li><a href="javascript:;" class="auth-guan" data-type="3">关注TA</a></li>';
                        CardInfo += '<li><a href="javascript:;" class="auth-gong" data-type="6">公开说</a></li>';
                        CardInfo += '<li><a href="javascript:;" class="auth-qiao" data-type="7">悄悄说</a></li>';
                    }
                    else { //该菜单 用户 => 用户
                        CardInfo += '<li><a href="javascript:;" class="auth-song" data-type="1">送礼物</a></li>';
                        CardInfo += '<li><a href="javascript:;" class="auth-gong" data-type="6">公开说</a></li>';
                        CardInfo += '<li><a href="javascript:;" class="auth-qiao" data-type="7">悄悄说</a></li>';
                        if ($.CommonMainRoom.RoomUserInfo.RoomAnchor || $.CommonMainRoom.RoomUserInfo.RoomAdmin) { //我是 房间艺人 房管 超管
                            CardInfo += '<li><a href="javascript:;" class="auth-jin" data-type="4">禁言</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="41">解除禁言</a></li>';
                            CardInfo += '<li><a href="javascript:;" class="auth-ti" data-type="2">踢出房间</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="21">恢复进房</a></li>';
                        }
                        if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) { //我是房间艺人
                            CardInfo += '<li><a href="javascript:;" data-type="5">提升场控</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="51">撤销场控</a></li>';
                        }
                    }
                    CardInfo += '</ul>';
                    CardInfo += '</div>';
                    $("#J_UserCardPop").html(CardInfo);
                },
                //用户 权限 被操作的提示
                UserRoleTip: function (data, Type) {
                    $.CommonMainRoom.RoomAnchorInfo.RoomAnchor = true;
                    var msg = {};
                    if (Type == "Admin") {
                        msg = { //设置禁言
                            User1: $.CommonMainRoom.RoomAnchorInfo,
                            User2: data.RoomUserInfo,
                            Text: (data.RoomUserInfo.RoomAdmin) ? '{User2} 提升为场控。' : '{User2} 撤销场控。'
                        };
                        if (msg.User2) {
                            _ThisPage.Page.Chat.OutText(msg);
                        }
                    } else if (Type == "Black") {
                        // if(data.Type == 2){ //踢出房间
                        //     if(data.RoomUserInfo.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID){
                        //         onJsToAs({type:"EndLive"}); //结束直播
                        //         alert("您已被请出房间！");
                        //         window.document.location = _VirtualPath.Main;
                        //     }
                        //     return;
                        // }
                        msg = { //设置禁言
                            User1: data.RoomUserInfo_Admin,
                            User2: data.RoomUserInfo,
                        };
                        if (data.Type == 1 || data.Type == 3) {
                            msg.Text = (data.Type == 1) ? '{User2} 设置禁言5分钟。' : '{User2} 设置 解除禁言。';
                        } else if (data.Type == 2 || data.Type == 4) {
                            msg.Text = (data.Type == 2) ? '{User2} 踢出房间。' : '{User2} 设置 恢复进房。';
                        }
                        if (msg.User2) {
                            _ThisPage.Page.Chat.OutText(msg);
                        }
                    }
                },
                ////////////////////////////End 用户菜单//////////////////////////////
                //系统提示
                Tip: function (data, settings) {
                    //  $.WindowComponent.ShowAlert(data);
                    $.CommonMain.Modal_Tip(data, settings);
                },
                //冻结房间按钮
                FrozenRoom: {
                    Data: {
                        Block: false,
                    },
                    Init: function (data) {
                        if ($.CommonMainRoom.RoomUserInfo.IsAdmin) {
                            $(".head-tool-shift").show();
                        } else {
                            $(".head-tool-shift").hide();
                            $(".head-tool-shift").remove();//删除安全点点点点点
                        }

                        //警告窗口
                        var DialogWin;
                        //警告按钮
                        $("#J_AdminWarningBtn").off('click');
                        $('#J_AdminWarningBtn').on('click', function () {
                            DialogWin = dialog({
                                title: '房间警告',
                                content: $('#J_ModalWarningBox'),
                                id: 'ID_Modal_10008',
                                padding: '0'
                            });
                            DialogWin.show();
                        });
                        //警告提交按钮
                        $("#J_AdminWarning_SubmitBtn").off("click");
                        $("#J_AdminWarning_SubmitBtn").on("click", function () {
                            if(!$.CommonMainRoom.RoomUserInfo.IsAdmin){
                                $.CommonMain.Modal_Tip("管理员才能操作！", {Timeout: 2000});
                                return;
                            }
                            var _AValue = $.trim($("#J_AdminWarning_ContentText").val());
                            if(!_AValue){
                                $.CommonMain.Modal_Tip("请输入警告原因！", {Timeout: 2000});
                                return;
                            }

                            var Parm = {
                                type: $('#J_AdminWarning_Select').val(),            //type : 警告类型
                                content: _AValue,                                   //content : 警告内容
                                notify: $("input[name='annotify']:checked").val(),  //notify : 形式，房间通知，全服通知//通知类型:0-默认不通知,1-通知艺人自己,2-通知房间内所有用户,3-通知全服
                                integral: $("input[name='anscore']:checked").val(), //integral : 扣分
                                operation: $("input[name='anact']:checked").val()   //operation : 操作，结束直播，冻结房间//操作类型:0-警告,1-结束直播,2-冻结房间
                            };
                            Log.Out("警告：：：：", Parm);
                            $.CommonMainRoom.SocketIO.emit("WarningSet", Parm.type, Parm.content, Parm.notify, Parm.integral, Parm.operation);
                            DialogWin.close();
                            DialogWin = null;
                        });






                        /*
                        //冻结按钮
                        var elem_10008 = $('#J_ModalFreezeBox');
                        var dialog_10008;
                        $('#J_FreezeAnchorNickName').text($.CommonMainRoom.RoomAnchorInfo.NickName);
                        $("#J_AdminFrozenBtn").off('click');
                        $("#J_AdminFrozenBtn").on("click", function () {
                            dialog_10008 = dialog({
                                title: '冻结房间',
                                content: elem_10008,
                                id: 'ID_Modal_10008',
                                padding: '0'
                            });
                            dialog_10008.show();
                        });
                        $("#J_FreezeSure").off("click");
                        $("#J_FreezeSure").on("click", function () {
                            var _AValue = $.trim($("#J_FreezeValue").val());
                            if (_AValue != null) {
                                if (_AValue != '') {
                                    dialog_10008.close();
                                    $.CommonMain.Modal_Tip("冻结成功！", {Timeout: 2000});
                                    $.CommonMainRoom.SocketEmit.BlockSet(true, _AValue);
                                } else {
                                    $.CommonMain.Modal_Tip("请输入原因才能冻结！", {Timeout: 2000});
                                }
                            }
                        });
                        //结束直播按钮
                        $("#J_AdminLiveEndBtn").off('click');
                        $('#J_AdminLiveEndBtn').on('click', function () {
                            if (!$.CommonMainRoom.RoomInfo.Live) {
                                $.CommonMain.Modal_Tip("艺人还没开播呢！", {Timeout: 2000});
                            } else {
                                if (confirm('【确定】要结束该房间直播吗？')) {
                                    _ThisPage.Page.Video.CommonUtils.LiveEndEvent();
                                }
                            }

                        });
                         */
                        
                        
                    }
                },
                //金币不够，提示充值面板
                PayBoxPanel: {
                    Show: function () {
                        // $.WindowComponent.ShowWin({
                        //     Title: "系统提示",//标题
                        //     Content: {
                        //         text: "抱歉，您的金币不足哟～", onComplete: function () {
                        //         }
                        //     },//内容
                        //     Width: 300,//内容宽
                        //     Height: 100,//内容高
                        //     CallBack: function (e) {
                        //         if (e.type == 'yes') {
                        //             window.open('http://www.quanminxiu.tv/pay/');
                        //         }
                        //     }, //回调函数 【e.type == "yes,no,cancel"】
                        //     ButtonLabel: {YesLabel: "去充值", CancelLabel: "取 消"},//按钮 Label 写此参数时有按钮显示，不写时，无按钮显示。
                        //     TitleIcon: _VirtualPath.Static + "main/template/imax/js/windowcomponent/AlertIcon.png", //窗口ICON地址
                        //     IsBg: false, //是否显示背景
                        //     IsClose: true //是否有窗口 关闭按钮
                        // });
                        dialog({
                            title: '温馨提示',
                            content: '<div style="padding: 10px; text-align: center" class="art-content">抱歉，您的金币不足哟～</div>',
                            id: 'ID_Modal_10010',
                            padding: '0',
                            width: "300px",
                            ok: function () {
                                window.open(_VirtualPath.Main + 'pay/');
                            },
                            okValue: '去充值',
                        }).show();

                    }
                },
                //显示座骑
                ShowMounts: {
                    Data: {
                        IsShowing: false, //是否 座骑显示中
                        Arr: [] //座骑队列
                    },
                    Init: {},
                    AddData: function (data) {
                        //Log.Out("座骑进场", data);
                        if (_ThisPage.Flash.Data.isInit) {
                            onJsToAs({type: "EnterSceneMountEffect", data: data});
                        } else {
                            _ThisPage.Flash.Data.Event.push({type: "EnterSceneMountEffect", data: data});
                        }

                        // _ThisPage.Page.CommonUitls.ShowMounts.Data.Arr.push(data);
                        // _ThisPage.Page.CommonUitls.ShowMounts._ShowEffect();
                    },
                    _ShowEffect: function () {
                        var _This = _ThisPage.Page.CommonUitls.ShowMounts;
                        if (_This.Data.IsShowing) return;
                        _This.Data.IsShowing = true;

                        if (_This.Data.Arr.length <= 0) return;

                        var data = _This.Data.Arr[0];
                        _This.Data.Arr.splice(0, 1);

                        var html = '<object width="100%" height="100%" align="middle" data="' + _VirtualPath.Static + 'main/image/mount/car' + data.MountsInfo.id + '.swf" type="application/x-shockwave-flash">' +
                            '<param value="high" name="quality">' +
                            '<param value="true" name="play">' +
                            '<param value="false" name="loop">' +
                            '<param value="transparent" name="wmode">' +
                            '<param value="false" name="menu">' +
                            '<param value="false" name="devicefont">' +
                            '<param value="" name="salign">' +
                            '<param value="always" name="allowscriptaccess">' +
                            '<param value="true" name="allowfullscreen">' +
                            '</object>' +
                            '<div class="WelcomeMountUserName">' +
                            '<span class="tag-user-level ico-level-' + data.UserInfo.Level + '"></span>' + data.UserInfo.NickName +
                            '</div>';
                        $('#J_MountsEffect').empty().append(html);

                        setTimeout(function () {
                            $('#J_MountsEffect').empty();
                            _This.Data.IsShowing = false;
                            if (_This.Data.Arr.length > 0) {
                                _This._ShowEffect();
                            }
                            ;
                        }, data.MountsInfo.EffectDuration + 100);
                    }
                },
                //类似活动操作方式(功能)
                NewClass_Toggle: function (Dom1, Dom2, Time, Callback) {
                    var TempTime = 0;
                    var TempTime2 = 0;
                    var ActivitContentIsShow = false;
                    Dom1.off("mouseenter");
                    Dom1.on("mouseenter", function () {
                        if (ActivitContentIsShow) {
                            clearTimeout(TempTime);
                            clearTimeout(TempTime2);
                            return;
                        }
                        ShowActivitContent();
                    });
                    Dom1.off("mouseleave");
                    Dom1.on("mouseleave", function () {
                        if (!ActivitContentIsShow) {
                            clearTimeout(TempTime);
                            clearTimeout(TempTime2);
                            return;
                        }
                        HideActivitContent();
                    });

                    Dom2.off("mouseenter");
                    Dom2.on("mouseenter", function () {
                        if (ActivitContentIsShow) {
                            clearTimeout(TempTime);
                            clearTimeout(TempTime2);
                        }
                    });
                    Dom2.off("mouseleave");
                    Dom2.on("mouseleave", function () {
                        if (!ActivitContentIsShow) return;
                        HideActivitContent();
                    });
                    function ShowActivitContent() {
                        clearTimeout(TempTime);
                        clearTimeout(TempTime2);
                        TempTime = setTimeout(function () {
                            ActivitContentIsShow = true;
                            callback(true);
                        }, Time);
                    }

                    function HideActivitContent() {
                        clearTimeout(TempTime);
                        clearTimeout(TempTime2);
                        TempTime2 = setTimeout(function () {
                            ActivitContentIsShow = false;
                            callback(false);
                        }, Time);
                    }

                    function callback(IsShow) {
                        if (Callback) {
                            Callback({IsShow: IsShow});
                        }
                    }
                }
            },
            /**
             * 房间相关
             */
            Room: {
                Data: {
                    Attention: false, //是否已关注
                },
                Common: {
                    Attention: function (User_ID, NickName) {
                        $.CommonMain.User_Attention(User_ID, null, function (json) {
                            Log.Out("添加关注结果", json);
                            if (json.flag != 0) {
                                _ThisPage.Page.Chat.SysText(json.msg);
                                return;
                            }
                            _ThisPage.Page.Chat.SysText('我 成功关注【' + NickName + '】！');
                            _ThisPage.Page.Room.MyAttention();
                        });
                    }
                },
                //初始化
                Init: function (data) {
                    $("#J_SideBarContent").perfectScrollbar();
                    var LiveTime = (data.RoomInfo.Live_CreateDate != undefined) ? moment(data.RoomInfo.Live_CreateDate).format('HH:mm')+' 开播' : '未开播';
                    $('#J_Live_CreateDate').text(LiveTime);
                    _ThisPage.Page.Room.InitAttention(data);
                    if (_StateData.IsLogin) {
                        _ThisPage.Page.Room.MyAttention();
                        $("#J_Panel_MyFollow").show();
                    }
                },
                //初始化 关注按钮功能
                InitAttention: function (data) {
                    _ThisPage.Page.Room.Data.Attention = data.Attention;
                    //关注按钮
                    updateAttentionBtnText();
                    $("#J_AttentionBtn").off("click");
                    $("#J_AttentionBtn").on("click", function (e) {
                        if (!$.CommonMain.LoginCheck()) return;
                        if ($.CommonMainRoom.RoomUserInfo.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID) {
                            Log.Out("艺人不能关注自己");
                            return;
                        }
                        _ThisPage.Page.Room.Data.Attention = !_ThisPage.Page.Room.Data.Attention;
                        Log.Out("关注 RoomID ", $.CommonMainRoom.RoomAnchorInfo.RoomID);
                        if (_ThisPage.Page.Room.Data.Attention) {
                            //添加关注
                            _ThisPage.Page.Room.Common.Attention($.CommonMainRoom.RoomAnchorInfo.RoomID, $.CommonMainRoom.RoomAnchorInfo.NickName);
                        } else {
                            $.CommonMain.User_Attention($.CommonMainRoom.RoomAnchorInfo.RoomID, _ThisPage.Page.Room.Data.Attention, function (json) {
                                Log.Out("取消关注结果", json);
                            }); //取消关注
                        }
                        (_ThisPage.Page.Room.Data.Attention) ? $.CommonMainRoom.RoomAnchorInfo.Fans++ : $.CommonMainRoom.RoomAnchorInfo.Fans--;
                        $("#J_AttentionNum").text($.CommonMainRoom.RoomAnchorInfo.Fans);
                        updateAttentionBtnText();
                    });
                    //更新关注按钮 文字
                    function updateAttentionBtnText() {
                        var AttentionText = (_ThisPage.Page.Room.Data.Attention) ? "已关注" : "关注";
                        $("#J_AttentionBtn").text(AttentionText);
                        if (_ThisPage.Page.Room.Data.Attention) {
                            $('.head-tool-follow').addClass('head-tool-followed');
                        } else {
                            $('.head-tool-follow').removeClass('head-tool-followed');
                        }
                    }
                },
                //更新房间相关信息
                UpdateInfo: function (data) {
                    Log.Out("Room.UpdateInfo。。。 ", data);
                    if (!data) return;
                    var LiveTime = (data.Live_CreateDate == undefined) ? '未开播' : moment(data.Live_CreateDate).format('HH:mm')+' 开播';
                    $('#J_Live_CreateDate').text(LiveTime);

                    $('.head-info-title').text(data.Live_Title);
                    $('#J_RoomWelcome').text(data.Live_Notice);
                    $('#J_RoomAnchorLiveTitle').val(data.Live_Title);
                    $('#J_RoomAnchorLiveNotice').val(data.Live_Notice);

                },
                //我的关注列表
                MyAttention: function () {
                    $.ajax({
                        url: '/ajax/user.user-attention.page',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            P_Get: true,
                            P_Total: 0,//总条数
                            P_MaxCode: "",//MaxCode
                            iDisplayStart: 0,//开始
                            iDisplayLength: 6,//页长度
                        },
                        success: function (data) {
                            if (data.flag !== 0) {
                                $.CommonMain.Modal_Tip(data.msg, {Timeout: 2000});
                                return;
                            }
                            $("#J_Panel_MyFollowTotal").html('(' + data.iTotalRecords + ')')
                            var _html = '';
                            _.forEach(data.aaData, function (Value) {
                                var _Live = '';
                                if (Value.Live == 1) {
                                    _Live = '<i class="living"></i>';
                                }

                                // if(Value.Live == 1 && Value.Live_IsMobile == 1){
                                //     _Live = '<i class="living-mobile"></i>';
                                // }
                                _html += '<li>' +
                                    '<a href="/room/' + Value.User_ID + '" target="_blank">' +
                                    '<img alt="' + Value.NickName + '" src="' + $.Common.ImageBind.UserAvatar.fnURL(Value.User_ID, "54.54") + '" class="cover">' +
                                    '<span class="nickname"><span class="tag-anchor-level ico-anchor-level-' + Value.Anchor_Level + '" title="Level-' + Value.Anchor_Level + '"></span>' + Value.NickName + '</span>' +
                                    '<p class="hotheart">' + Value.Anchor_HotValue + '</p>' +
                                    _Live +
                                    '</a>' +
                                    '</li>';
                            });
                            $('#J_Panel_MyFollowList').empty().append(_html);
                        }
                    });
                }
            },
            /**
             * 艺人相关
             */
            Anchor: {
                Init: function (data) {
                    $('#J_RoomAnchorHeadImg').attr('src', _ThisPage.Page.CommonUitls.GetUserHand(data.RoomAnchorInfo.RoomID, '80.80'));
                    $('#J_RoomAnchorHeadImg').attr('alt', data.RoomAnchorInfo.NickName);
                    this.InitBadge();
                    $("#J_RoomAnchorHeadImg").on('mouseenter', function (event) {
                        event.preventDefault();
                        $("#J_AnchorUpgradeBox").addClass("expand");
                    });
                    $("#J_RoomAnchorHeadImg").on('mouseleave', function (event) {
                        event.preventDefault();
                        $("#J_AnchorUpgradeBox").removeClass("expand");
                    });
                },
                //保存编辑房间信息
                SaveRoomWelcomeInfo: function (RoomWelcome) {
                    $.ajax({
                        url: '/ajax/user.user-anchor.update',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            RoomWelcome: RoomWelcome
                        },
                        success: function (data) {
                            if (data.flag !== 0) {
                                _ThisPage.Page.CommonUitls.Tip(data.msg);
                                return;
                            }
                            // _ThisPage.Page.CommonUitls.Tip("房间信息修改成功");
                        }
                    });
                },
                //更新艺人相关信息
                UpdateInfo: function (data) {
                    // $("#J_PicThumb").attr("src", _ThisPage.Page.CommonUitls.GetUserHand(data.RoomID,"80.80"));//艺人头像
                    $("#J_Anchor_NickName").text(data.NickName).attr("title", data.NickName);//艺人昵称
                    // $("#J_RoomWelcome").text(data.RoomWelcome); //房间描述数据
                    // $("#J_RoomWelcomeTxt").val(data.RoomWelcome); //房间描述数据
                    // $("#J_Anchor_Attention").text(data.Fans);//艺人关注人数 【Anchor_Attention这个数据是艺人关注了多少人】
                    // $("#J_AnchorPomeloNum").text(data.Pomelo);//艺人的星星
                    // $("#J_Anchor_EXP").text(data.EXP);//艺人经验
                    // $("#J_Anchor_EXP_Difference").text(data.EXP_Difference);//艺人差多少经验升级
                    var prcent = ( (data.EXP / data.EXP_Next).toFixed(2) * 100 ) + "%";//升级差距进度条
                    data.Level = (data.Level == 0) ? 1 : data.Level; //艺人等级 从1开始
                    $('#J_AnchorPomeloNum').text(data.Pomelo);
                    $("#J_AttentionNum").text($.CommonMainRoom.RoomAnchorInfo.Fans);
                    // $('#J_RoomUserCount').text('-');
                    $('#J_RoomAnchorLevelIcon').html('<span class="tag-anchor-level ico-anchor-level-' + data.Level + '"></span>');
                    $('#J_AnchorUpgradeProgress').attr("style", "width:" + prcent);
                    $('#J_AnchorUpgradeLevel').html('升级到<span class="tag-anchor-level ico-anchor-level-' + data.Level_Next + '"></span>');
                    $('#J_AnchorUpgradeNeed').html('还需<span class="c-lev">' + data.EXP_Difference + '</span>经验');

                    if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                        $('#J_UserInfo_Bean').text(data.Beans);
                    }
                },
                //初始化 艺人徽章
                InitBadge: function () {
                    //徽章暂时去掉了。。。
                    return;
                    var anchorHZ = $.CommonMainRoom.RoomAnchorInfo.EmblemList;
                    var hz = _PageData.Commodity.Emblem.Data;
                    // if(anchorHZ == null) return;
                    if (hz == null) return;
                    $('#J_AnchorBadgeList i').remove('.ico-info-badge');
                    for (var i = 0; i < hz.length; i++) {
                        var hzObj = hz[i];
                        if (hzObj.Type == 1 && !hzObj.Status) {
                            var status = GetAnchorIndex(anchorHZ, hzObj.ID);
                            var imgTitle = (status == '0') ? hzObj.Name : "周星 - " + hzObj.Name;
                            var img = '<i class="ico-info-badge ico-badge-' + hzObj.ID + '" title="' + imgTitle + '"></i>';
                            if (status == "1") $("#J_AnchorBadgeList").append(img);
                        }
                    }

                    function GetAnchorIndex(anchorHZ, hzID) {
                        if (!anchorHZ) return "0";
                        for (var i = 0; i < anchorHZ.length; i++) {
                            if (anchorHZ[i].Item_ID == hzID) {
                                return "1";
                            }
                        }
                        return "0";
                    }
                }
            },
            /**
             * 自己相关的
             */
            Self: {
                Data: {},
                //个人名片 自己的 用户信息
                Init: function (data) {
                    //徽章
                    // $("#J_SelfInfoBadge").html(_ThisPage.Page.Chat.CommonUtils.GetBadgeIconHtml($.CommonMainRoom.RoomUserInfo.EmblemList));


                    $("#J_SidebarCollapseMemberCover").on("mouseenter",function(){
                        $("#J_C_SideBarMember").show()
                    });
                    $("#J_SidebarCollapseMemberCover").on("mouseleave",function(){
                        $("#J_C_SideBarMember").hide()
                    });
                },
                UpdateInfo: function (data) {
                    // $("#J_MUser_Level").attr('alt', data.Level);
                    // $("#J_MUser_Level").attr('src',_VirtualPath.Static+"main/image/common/level/user/"+data.Level+".png");
                    if(data.User_ID == undefined) return;
                    var prcent = (data.EXP / data.EXP_Next).toFixed(2) * 100 + "%";
                    $("#J_MUser_Exp,#J_C_MUser_Exp").css('width', prcent);
                    $("#J_UserInfo_Cover,#J_C_UserInfo_Cover,#J_C_UserinfoCover").attr({
                        "src": _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID),
                        "alt": data.NickName
                    });
                    // $("#J_MUser_Diff").text(data.EXP_Difference);
                    // $("#J_MiniUserHeadImg").attr("src", _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID));
                    $("#J_UserInfo_Nickname,#J_C_UserInfo_Nickname").text(data.NickName);
                    $('#J_UserInfo_ID,#J_C_UserInfo_ID').text('ID:' + data.User_ID);
                    $('#J_UserInfo_Coin,#J_C_UserInfo_Coin').text(data.Coin);
                    $('#J_UserInfo_Bean,#J_C_UserInfo_Bean').text(data.Beans);

                    //需要 更新人员列表
                    // if ($("#J_UserList li[data-uid=" + data.User_ID + "] .J_UserLevelIcon").find("img").length > 0) {
                    //     var level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                    //     var path = data.RoomAnchor ? "anchor/" : "user/";
                    //     path =  _VirtualPath.Static+'main/image/common/level/'+path+level+'.png';
                    //     $("#J_UserList li[data-uid=" + data.User_ID + "] .J_UserLevelIcon img").attr("src",path);
                    // }
                }
            },
            /**
             * 视频相关
             */
            Video: {
                Data: {
                    IsChangeCdn: false,
                    LiveWin: null //开播窗口
                },
                CommonUtils: {
                    //开始直播事件
                    LiveStartEvent: function (Title, Notice) {
                        $('.head-info-title').text(Title);
                        $('#J_RoomAnchorLiveTitle').val(Title);
                        $('#J_RoomWelcome').text(Notice);
                        $('#J_RoomAnchorLiveNotice').val(Notice);
                        $.CommonMainRoom.SocketEmit.Live(Title, Notice);
                    },
                    //结束直播事件
                    LiveEndEvent: function () {
                        $.CommonMainRoom.SocketEmit.LiveEnd();
                    }
                },
                //初始化
                Init: function (data) {
                    var _This = _ThisPage.Page.Video;
                    _This.GetRecommend(!$.CommonMainRoom.RoomInfo.Live);
                    _This.Playing($.CommonMainRoom.RoomInfo.Live);
                    _ThisPage.Flash.JoinRoom($.CommonMainRoom.RoomInfo);
                    if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                        if ($.CommonMainRoom.RoomInfo.Live) {
                            _ThisPage.Page.Video.ShowLiveBtn(false);
                            $("#J_LiveStartBtn").hide();
                            $("#J_LiveEndBtn").hide();
                        } else {
                            _ThisPage.Page.Video.ShowLiveBtn(true);
                            $("#J_LiveStartBtn").show();
                            $("#J_LiveEndBtn").hide();
                            //第二次进入房间 艺人页 显示结束直播界面
                            _ThisPage.Page.Video.LiveEnd();
                        }
                    }

                    //剪切板事件
                    var clipboard = new Clipboard('.x-control-btn');
                    clipboard.on('success', function (e) {
                        $.CommonMain.Modal_Tip("复制成功，快去粘贴到OBS的！", {Timeout: 1000});
                    });
                    clipboard.on('error', function (e) {
                        $.CommonMain.Modal_Tip("复制失败，快去手动复制，分享给好友吧！", {Timeout: 1000});
                    });

                    //开始直播/结束直播
                    $("#J_LiveStartBtn").off("click");
                    $("#J_LiveStartBtn").on("click", function () {
                        Log.Out("开始直播");
                        // $("#J_LiveStarSwpBtn").hide();
                        // $('.player-live-btn').show();
                        // $("#J_LiveEndBtn").hide();
                        // onJsToAs( { type:"SelectCamear" } );

                        $('#J_LiveRtmpCopyBtn,#J_LiveRtmpCodeCopyBtn').removeClass('active');
                        _This.Data.LiveWin = dialog({
                            title: '开播流程',
                            content: $('.modal-liveplay-box'),
                            id: 'ID_Modal_10001',
                            padding: '0'
                        }).show();


                        //剪切板内容
                        $('#J_LiveRtmpText').val($.CommonMainRoom.RoomInfo.Live_PUSH);
                        $('#J_LiveRtmpText').attr('data-clipboard-text', $.CommonMainRoom.RoomInfo.Live_PUSH);
                        $('#J_LiveRtmpCodeText').val($.CommonMainRoom.RoomInfo.Live_Code);
                        $('#J_LiveRtmpCodeText').attr('data-clipboard-text', $.CommonMainRoom.RoomInfo.Live_Code);

                        $('#J_LiveRtmpCopyBtn,#J_LiveRtmpCodeCopyBtn').off('click');
                        $('#J_LiveRtmpCopyBtn,#J_LiveRtmpCodeCopyBtn').on('click', function () {
                            $(this).addClass('active');
                        });

                    });
                    $("#J_LiveEndBtn").off("click");
                    $("#J_LiveEndBtn").on("click", function () {
                        Log.Out("结束直播");
                        $("#J_LiveEndBtn").hide();
                        _This.CommonUtils.LiveEndEvent();
                    });

                    //开播窗口 中的 开始直播按钮
                    $('.x-box-split-btn>.x-control-btn-live').off('click');
                    $('.x-box-split-btn>.x-control-btn-live').on('click', function () {
                        var Title = _ThisPage.Page.Chat.MsgFilter($('#J_RoomAnchorLiveTitle').val());
                        var Notice = _ThisPage.Page.Chat.MsgFilter($('#J_RoomAnchorLiveNotice').val());

                        if(Title.length < 1){
                            _ThisPage.Page.CommonUitls.Tip("请输入【直播标题】,再点【开始直播】按钮", {Timeout:3000});
                            $('#J_RoomAnchorLiveTitle').focus();
                            return;
                        }

                        //艺人选择 摄像头 设备
                        // onJsToAs( { type:"SelectCamear" } );
                        //播放视频地址
                        // onJsToAs( { type:"PlayVideo", rtmpUrl:$('#J_LiveRtmpText').attr('data-clipboard-text')+$('#J_LiveRtmpCodeText').attr('data-clipboard-text') } );

                        $('.player-live-btn').hide();
                        $("#J_LiveStartBtn").hide();
                        $("#J_LiveEndBtn").hide();

                        _This.CommonUtils.LiveStartEvent(Title, Notice);
                        _This.Data.LiveWin.close().remove();
                    });
                    //切换大屏小屏
                    $("#J_LiveSwpBtn").off("click");
                    $("#J_LiveSwpBtn").on("click", function () {

                        // Log.Out("开始直播");
                        // $("#J_LiveStarSwpBtn").hide();
                        // $("#J_LiveEndBtn").hide();
                        // onJsToAs( { type:"SelectCamear" } );
                        // return;

                        Log.Out("切换大屏");
                        $.ajax({
                            url: '/ajax/user.user-anchor.update',
                            type: 'post',
                            dataType: 'json',
                            data: {
                                RoomTemplate: "iMax", //RoomTemplate ("Classic", "iMax")
                                Live_IsMobile: 0 //是否 手机直播
                            },
                            success: function (data) {
                                Log.Out("切换大屏", data);
                                if (data.flag !== 0) {
                                    _ThisPage.Page.CommonUitls.Tip("Error " + data.msg + " " + data.flag);
                                    return;
                                }
                                _ThisPage.Page.CommonUitls.Tip("切换【大屏直播间】成功！");
                                setTimeout(function () {
                                    window.location.reload();
                                }, 2000);
                            }
                        });
                    });


                    _This.Activity.Init(data);
                },
                //获取 推荐位
                GetRecommend: function (isShow) {
                    if ($.CommonMainRoom.RoomUserInfo.RoomAnchor)return;
                    if (!isShow) {
                        //清空 隐藏
                        $("#J_RecommendAnchor").hide();
                        return;
                    }

                    $("#J_RecommendAnchor").show();
                    $.ajax({
                        url: '/ajaxs/rcommon.useranchorlisthot.get',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            Start:0,
                            Length:3
                        },
                        success: function (data) {
                            //Log.Out("推荐艺人 ", data);
                            if (data.flag !== 0) {
                                _ThisPage.Page.CommonUitls.Tip("Error " + data.msg + " " + data.flag);
                                return;
                            }
                            _ThisPage.Page.Video.AddRecommend(data.data);
                        }
                    });
                },
                //添加推荐艺人
                AddRecommend: function (allData) {
                    var s = "";
                    for (var i = 0; i < allData.length; i++) {
                        var _LiveState = '';
                        var data = allData[i];
                        if (data.Live == 1) {
                            var _LiveState = '<i class="living"></i>';
                        }
                        var itemHtml = '<li>';
                        itemHtml += '<a href="' + _VirtualPath.Main + 'room/' + data.User_ID + '" target="_blank" class="cover">';
                        itemHtml += '<img src="' + _ThisPage.Page.CommonUitls.GetAvatarHand(data.User_ID, "294.294") + '" alt="' + data.NickName + '">';
                        itemHtml += '<span class="v-enter">进入直播间</span>';
                        itemHtml += _LiveState;
                        itemHtml += '</a>';
                        itemHtml += '<h3><a  href="' + _VirtualPath.Main + 'room/' + data.User_ID + '" target="_blank">' + (data.RoomTitle == '' ? '-' : data.RoomTitle) + '</a></h3>';
                        itemHtml += '<p><a  href="' + _VirtualPath.Main + 'room/' + data.User_ID + '" target="_blank" class="nickname">' + data.NickName + '</a><span class="viewtotal">' + data.Anchor_HotValue + '</span></p>';
                        itemHtml += '</li>';
                        s += itemHtml;
                    }
                    $("#J_RecommendAnchorList").html(s);
                },
                //是否显示 开始直播/结束直播
                ShowLiveBtn: function (isShow) {
                    if (isShow) {
                        // Log.Out("显示开播按钮");
                        $(".player-live-btn").show();
                    } else {
                        Log.Out("隐藏开播按钮");
                        $(".player-live-btn").hide();
                    }
                },
                //收到艺人结束直播动作
                LiveEnd: function () {
                    _ThisPage.Flash.EndLive();
                    if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                        $('.player-live-btn').show();
                        $("#J_LiveStartBtn").show();
                        $("#J_LiveEndBtn").hide();
                    } else {
                        _ThisPage.Page.Video.GetRecommend(true);
                    }
                    _ThisPage.Page.Video.Activity.ActivityLink(false);

                    //如果是切换CDN的话，就自动开播。
                    if (_ThisPage.Page.Video.Data.IsChangeCdn) {
                        _ThisPage.Page.Video.Data.IsChangeCdn = false;
                        $.CommonMainRoom.SocketEmit.Live();
                    }
                },
                //是否播放视频中
                Playing: function (isPlaying) {
                    if (isPlaying) {
                        _ThisPage.Page.Video.Activity.ActivityLink(true);
                        _ThisPage.Page.Video.LoginBar.Init(true);
                        _ThisPage.Page.Video.UserGuide.Init(true);
                    } else {
                        _ThisPage.Page.Video.Activity.ActivityLink(false);
                        _ThisPage.Page.Video.LoginBar.Init(false);
                        _ThisPage.Page.Video.UserGuide.Init(false);
                    }
                },
                LoginBar: {
                    Init: function (isShow) {
                        if (isShow && !_StateData.IsLogin) {
                            setTimeout(function () {
                                var _Html = '<div class="main-login-mask" id="J_MainLoginMask"></div>' +
                                    '<div class="main-login-bar" id="J_MainLoginBar">' +
                                    '<a href="javascript:;" class="main-login-closed" id="J_MainLoginClosed"></a>' +
                                    '<div class="main-login-content">' +
                                    '<h2 class="main-login-hd">即刻登录，3000金币等你拿</h2>' +
                                    '<div class="main-login-bd">' +
                                    '<a href="javascript:;" class="qqlogin" UserOAuth="QQ">QQ登录</a>' +
                                    '<a href="javascript:;" class="wxlogin" UserOAuth="Weixin">微信登录</a>' +
                                    '<a href="javascript:;" class="wblogin" UserOAuth="Weibo">微博登录</a>' +
                                    '<a href="javascript:;" class="xylogin" usersign="In">全民秀登录</a>' +
                                    '</div>' +
                                    '</div>' +
                                    '</div>';
                                $("#J_MainPlayerContent").append(_Html);
                                $('#J_MainLoginBar').css({
                                    bottom: "-228px"
                                });
                                $('#J_MainLoginBar').animate({bottom: "0px"}, 750);
                            }, 75000);
                        }

                        $("body").delegate("#J_MainLoginClosed", "click", function (event) {
                            $("#J_MainLoginBar,#J_MainLoginMask").remove();
                        });

                    }
                },
                //活动 ICON
                Activity: {
                    Init: function (data) {
                        // //是否【最美COSER】艺人
                        // if (_.includes($.CommonMainRoom.RoomAnchorInfo.Tags, "最美COSER")) {
                        //     _ThisPage.Page.PomeloUtil.Data.GiftId = '00';
                        //     _ThisPage.Page.PomeloUtil.Data.GiftName = '八芒星';
                        //     $('.icon-pomelo').addClass('icon-bastar').removeClass('icon-pomelo');
                        //     $("#J_ActivityLink").hide();
                        //     $('#J_ActivityLink_coser').show();
                        //     $('#J_ActivitRankContent_coser').hide();
                        //     //【最美COSER】活动
                        //     var toggle2 = new _ThisPage.Page.CommonUitls.NewClass_Toggle($("#J_ActivityIcon_coser"), $("#J_ActivitRankContent_coser"), 500, function (e) {
                        //         if (e.IsShow) {
                        //             // $("#J_ActivitRankContent_coser").append('<div class="ajaxloading"><img src="image/loading.gif" alt="">加载中...</div>');
                        //             $("#J_ActivitRankContent_coser").show();
                        //             if ($('#J_ActivitRankContentList_coser li').length > 0) return;
                        //
                        //             $.getJSON(_VirtualPath.Main + "ajax/business.user-coserticket", {
                        //                 User_ID: $.CommonMainRoom.RoomInfo.RoomID,
                        //                 Length: 5
                        //             }, function (json) {
                        //                 if (json.flag !== 0) {
                        //                     _ThisPage.Page.CommonUitls.Tip("Error " + json.msg + " " + json.flag);
                        //                     return;
                        //                 }
                        //                 Log.Out("【最美COSER】排行数据", json.data);
                        //                 var data = json.data;
                        //                 $('#J_CoserTotalRankingImg').attr('src', $.Common.ImageBind.UserAvatar.fnURL(data.User_ID, "54.54"));
                        //                 $('#J_CoserTotalRanking').text(data.AnchorRanking);
                        //                 $('#J_CoserTotalRankCount').text(data.AnchorRankTicketNum);
                        //                 var html = '';
                        //                 for (var i = 0; i < data.AnchorRankList.length; i++) {
                        //                     var ii = i + 1;
                        //                     var anchorInfo = data.AnchorRankList[i];
                        //                     html += '<li>' +
                        //                         '<a href="/special/coser2016/" target="_blank">' +
                        //                         '<span class="rank-num rank-num-' + ii + '">' + ii + '</span>' +
                        //                         '<img alt="' + anchorInfo.NickName + '" src="' + $.Common.ImageBind.UserAvatar.fnURL(anchorInfo.User_ID, "54.54") + '" class="cover">' +
                        //                         '<p class="info">' +
                        //                         '<span class="tag-anchor-level ico-anchor-level-' + anchorInfo.Level + '"></span>' +
                        //                         '<span class="nickname">' + anchorInfo.NickName + '</span>' +
                        //                         '</p>' +
                        //                         '<p class="total">当前票数：' + anchorInfo.Ticket + ' 票</p>' +
                        //                         '</a>' +
                        //                         '</li>';
                        //                 }
                        //                 $('#J_ActivitRankContentList_coser').empty().append(html);
                        //             });
                        //         } else {
                        //             $("#J_ActivitRankContent_coser").hide();
                        //         }
                        //     });
                        // }else{
                        //     // $("#J_ActivityLink_giving").show();
                        // }
                    },
                    ActivityLink: function (isShow) {
                        // if (isShow) {
                        //      $("#J_ActivityLink").show();
                        // } else {
                        //      $("#J_ActivityLink").hide();
                        // }
                    },

                },
                //用户引导
                UserGuide: {
                    Init: function (data) {
                        this.TaskGuide(data);
                        this.AttentionGuide(data);
                    }
                    ,
                    TaskGuide: function (data) {
                        if (data && !_StateData.IsLogin) {
                            setTimeout(function () {
                                var TPosL,TPosT;
                                var _Taskpos= $('[data-task="task"]');
                                if($('body').hasClass('expand-state')){
                                    TPosL = _Taskpos.eq(0).offset().left + 58;
                                    TPosT = _Taskpos.eq(0).offset().top - 118;
                                }else{
                                    TPosL = _Taskpos.eq(1).offset().left + 38;
                                    TPosT = _Taskpos.eq(1).offset().top - 108;
                                }
                                $("#J_GuideTaskTip").css({
                                    "left": TPosL,
                                    "top": TPosT
                                }).show();
                            }, 1000);
                            setTimeout(function () {
                                $("#J_GuideTaskTip").hide();
                            }, 30000);
                        } else {
                            $("#J_GuideTaskTip").hide();
                        }
                        $("#J_GuideTaskTip").on("click", "a.x-closed", function (event) {
                            $("#J_GuideTaskTip").hide();
                        });
                    }
                    ,
                    AttentionGuide: function (data) {
                        if (data && !_StateData.IsLogin) {
                            setTimeout(function () {
                                var left = $(".head-tool-follow").offset().left - 135;
                                var top = $(".head-tool-follow").offset().top + 15;

                                $("#J_GuideAttentionTip").css({
                                    "left": left,
                                    "top": top
                                }).show();
                            }, 45000);
                            setTimeout(function () {
                                $("#J_GuideAttentionTip").hide();
                            }, 60000);
                        } else {
                            $("#J_GuideAttentionTip").hide();
                        }
                        $("#J_GuideAttentionTip").on("click", "a.x-closed", function (event) {
                            $("#J_GuideAttentionTip").hide();
                        });
                    }

                }
            },
            /**
             * 聊天
             */
            Chat: {
                Data: {
                    Word: [],//脏话 过滤词
                    Intreval: 0,//发言时间间隔
                    Maxlength: 0,//发送文字最长限制
                    isCanSend: true,//是否 可以发送文字
                    isMouseAreaFaceEmo: false,//鼠标是否在 表情区域
                    MsgMaxCount: 100,//最大条数
                    TestInterval: 0,//测试Interval
                    TestMaxCount: 0,//测试消息条数
                    TestCurrCount: 0,//测试数据当前条数

                    MsgArr: [],//当前消息 xxx
                    MsgObj: null,//当前消息

                    IsPrivate: false, //是否 私聊区
                    IsHorn: false, //是否 喇叭状态
                    IsFly: false, //是否 飞屏状态
                    LastPlaceholder: '', //上次的提示
                    IsLockScroll: false, //是否 锁定滚动区

                    GuestEnterTempTime:0,//游客进入的功能，显示10秒后消失。

                    ChatUser: { //公聊 私聊 切换数据
                        Receiver: null,
                        Private: false,
                        PrivateTa: false
                    },
                    Config: [
                        //等级    发言间隔    聊天字数    是否允许私聊
                        {level: 0, interval: 1, char: 20, private: 0},
                        {level: 1, interval: 1, char: 30, private: 0},
                        {level: 2, interval: 1, char: 30, private: 0},
                        {level: 3, interval: 1, char: 30, private: 1},
                        {level: 4, interval: 1, char: 30, private: 1},
                        {level: 5, interval: 1, char: 30, private: 1},
                        {level: 6, interval: 1, char: 30, private: 1},
                        {level: 7, interval: 1, char: 30, private: 1},
                        {level: 8, interval: 1, char: 30, private: 1},
                        {level: 9, interval: 1, char: 30, private: 1},
                        {level: 10, interval: 1, char: 30, private: 1},
                        {level: 11, interval: 1, char: 30, private: 1},
                        {level: 12, interval: 1, char: 30, private: 1},
                        {level: 13, interval: 1, char: 30, private: 1},
                        {level: 14, interval: 1, char: 30, private: 1},
                        {level: 15, interval: 1, char: 30, private: 1},
                        {level: 16, interval: 1, char: 30, private: 1},
                        {level: 17, interval: 1, char: 30, private: 1},
                        {level: 18, interval: 1, char: 30, private: 1},
                        {level: 19, interval: 1, char: 30, private: 1},
                        {level: 20, interval: 1, char: 30, private: 1},
                        {level: 21, interval: 1, char: 30, private: 1},
                        {level: 22, interval: 1, char: 30, private: 1},
                        {level: 23, interval: 1, char: 30, private: 1},
                        {level: 24, interval: 1, char: 30, private: 1},
                        {level: 25, interval: 1, char: 30, private: 1},
                        {level: 26, interval: 1, char: 30, private: 1},
                        {level: 27, interval: 1, char: 30, private: 1},
                        {level: 28, interval: 1, char: 30, private: 1},
                        {level: 29, interval: 1, char: 30, private: 1},
                        {level: 30, interval: 1, char: 30, private: 1},
                        {level: 31, interval: 1, char: 30, private: 1},
                        {level: 32, interval: 1, char: 30, private: 1},
                        {level: 33, interval: 1, char: 30, private: 1},
                        {level: 34, interval: 1, char: 30, private: 1},
                        {level: 35, interval: 1, char: 30, private: 1},
                        {level: 36, interval: 1, char: 30, private: 1}
                    ]
                },
                //测试自动发布消息
                TestAutoSendMsg: function () {
                    if (_ThisPage.Page.Chat.Data.TestCurrCount >= _ThisPage.Page.Chat.Data.TestMaxCount) {
                        clearInterval(_ThisPage.Page.Chat.Data.TestInterval);
                        $("#J_InputTextWord").val("game over");
                        _ThisPage.Page.Chat.Data.TestCurrCount = 0;
                        _ThisPage.Page.Chat.Data.TestMaxCount = 0;
                        return;
                    }
                    _ThisPage.Page.Chat.Data.TestCurrCount++;
                    $("#J_InputTextWord").val("Test Text " + _ThisPage.Page.Chat.Data.TestCurrCount);
                    var txt = $("#J_InputTextWord").val();
                    var msgObj = {};
                    msgObj.Private = false;
                    msgObj.PrivateTa = false;
                    msgObj.text = txt;
                    msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                    msgObj.User2 = null;
                    _ThisPage.Page.Chat.Data.MsgObj = msgObj;
                    // _ThisPage.Page.Chat.ChatShowMsg(msgObj);
                    $.CommonMainRoom.SocketEmit.Message(msgObj.text);
                },
                //公共方法
                CommonUtils: {
                    //获取用户名及等级图标
                    GetUserName: function (UserData, isPrivate) {
                        // Log.Out("公共方法 GetUserName", [UserData.RoomID, $.CommonMainRoom.RoomAnchorInfo.RoomID]);
                        var html = '';
                        if(!UserData.Guest){
                        var isRoomAnchor = (UserData.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID || UserData.RoomID == $.CommonMainRoom.RoomAnchorInfo.RoomID);
                        var anchorLevel = $.CommonMainRoom.RoomAnchorInfo.Level;
                        var userLevel = UserData.Level;
                        var level = isRoomAnchor ? anchorLevel : userLevel;
                            html = '<div class="main-chat-userinfo">';
                            html += '<div class="main-chat-tags">';
                            html += _ThisPage.Page.Chat.CommonUtils.GetUserIcon(UserData);
                            html += '</div>';
                            html += '<span title="' + UserData.NickName + '" data-uid=' + UserData.User_ID + ' class="chat-board-nickname' + ( (UserData.VIP) ? ' chat-board-vip-nickname' : '' ) + '">' + UserData.NickName + '</span>';
                            html += '</div>';
                        }else{
                            html += '<span title="' + UserData.NickName + '" data-uid=' + UserData.User_ID + ' class="chat-board-nickname' + ( (UserData.VIP) ? ' chat-board-vip-nickname' : '' ) + '">' + UserData.NickName + '</span>';
                        }
                        return html;
                    },
                    //获取用户ICON
                    GetUserIcon: function (UserData) {
                        var isRoomAnchor = (UserData.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID);
                        var anchorLevel = $.CommonMainRoom.RoomAnchorInfo.Level;
                        var userLevel = UserData.Level;
                        var level = (isRoomAnchor) ? anchorLevel : userLevel;
                        var html = '';
                        // Log.Out("用户ICON，",[UserData.NickName, isRoomAnchor, UserData.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID, UserData.RoomID == $.CommonMainRoom.RoomAnchorInfo.RoomID]);
                        if (!UserData.Guest) html += (isRoomAnchor) ? '<span class="main-chat-tag-anchor-level ico-anchor-level-' + anchorLevel + '" title="艺人等级-' + anchorLevel + '"></span>' : '<span class="main-chat-tag-user-level ico-level-' + userLevel + '" title="等级-' + userLevel + '"></span>';
                        if (UserData.IsMobile) html += '<span class="main-chat-tag-plat-mobile" title="手机"></span>';
                        if (UserData.VIP) html += '<span class="main-chat-tag-user-vip" title="VIP"></span>';
                        if (UserData.RoomAdmin) html += '<span class="main-chat-tag-user-admin" title="房间场控"></span>';
                        // if (UserData.IsAdmin) html += '<span class="main-chat-tag-user-official" title="官方"></span>';
                        if (UserData.RoomGuardian && (UserData.RoomGuardian_Mode == "MONTH" || UserData.RoomGuardianMode == "MONTH")) html += '<span class="main-chat-tag-user-guard-month" title="月守护"></span>';
                        if (UserData.RoomGuardian && (UserData.RoomGuardian_Mode == "YEAR" || UserData.RoomGuardianMode == "YEAR")) html += '<span class="main-chat-tag-user-guard-year" title="年守护"></span>';
                        if (UserData.EmblemList) html += _ThisPage.Page.Chat.CommonUtils.GetBadgeIconHtml(UserData.EmblemList);
                        return html;
                    },
                    //获取徽章
                    GetBadgeIconHtml: function (EmblemList) {
                        if (EmblemList == null) return;
                        if (typeof EmblemList == "String") return;
                        var s = "";
                        for (var i = 0; i < EmblemList.length; i++) {
                            if (EmblemList[i].Item_Type == 2) {
                                s += '<span class="main-chat-tag-user-badge main-chat-tag-user-badge-lv' + EmblemList[i].Item_ID + '" title="' + EmblemList[i].Item_Name + '"></span>'
                            }
                        }
                        return s;
                    },
                    //取消 飞屏 喇叭 状态
                    CancelHorn: {
                        All:function(){
                            _ThisPage.Page.Chat.CommonUtils.CancelHorn.Horn();
                            _ThisPage.Page.Chat.CommonUtils.CancelHorn.Fly();
                        },
                        Horn:function () {
                            var _This = _ThisPage.Page.Chat;
                            if (_This.Data.IsHorn) {
                                _This.Data.IsHorn = false;
                                $('#J_TalkMsgBtn').addClass('active');
                                $('#J_TalkHornBtn').removeClass('active');
                                $('.main-chat-sender').removeClass('main-chat-sender-horn');
                                $('#J_InputTextWord').val('');
                                $("#J_InputTextWord").attr("placeholder", _This.Data.LastPlaceholder);
                                if (_This.Data.LastPlaceholder.substr(0, 1) == '@') $("#J_PrivateCancel").show();
                                _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                                $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                            }
                        },
                        Fly:function () {
                            var _This = _ThisPage.Page.Chat;
                            if (_This.Data.IsFly) {
                                _This.Data.IsFly = false;
                                $('#J_TalkMsgBtn').addClass('active');
                                $('#J_TalkFlyBtn').removeClass('active');
                                $('.main-chat-sender').removeClass('main-chat-sender-fly');
                                $('#J_InputTextWord').val('');
                                $("#J_InputTextWord").attr("placeholder", _This.Data.LastPlaceholder);
                                if (_This.Data.LastPlaceholder.substr(0, 1) == '@') $("#J_PrivateCancel").show();
                                _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                                $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                            }
                        }
                    }
                },
                //初始化
                Init: function (data) {
                    //init 滚动条
                    $(".main-chat-info").perfectScrollbar();

                    var _This = this;
                    _ThisPage.Page.Chat.Data.isCanSend = true;
                    _This.Data.LastPlaceholder = $('#J_InputTextWord').attr('placeholder');
                    //发送按钮
                    $("#J_TalkPublishBtn").off('click');
                    $("#J_TalkPublishBtn").on('click', function (e) {
                        _ThisPage.Page.Chat.ChatSendEvent();
                    });
                    //输入框 回车
                    $("#J_InputTextWord").off('keyup');
                    $("#J_InputTextWord").on('keyup', function (e) {
                        if (e.keyCode == 13 && !_This.Data.IsHorn && !_This.Data.IsFly) {
                            _ThisPage.Page.Chat.ChatSendEvent();
                        }
                    });
                    //游客弹出登录框
                    $("#J_InputTextWord").focusin(function (e) {
                        $.CommonMain.LoginCheck();
                    });

                    //清除聊天区文字 按钮
                    $('#J_ChatTextClearBtn').off('click');
                    $('#J_ChatTextClearBtn').on('click', function (e) {
                        $('#J_Chatlistinfo').text('');
                        $("#J_WebChatList").scrollTop(0);
                        $('#J_ChatlistinfoPrivate').text('');
                        $("#J_WebChatListPrivate").scrollTop(0);
                    });

                    //聊天消息按钮
                    $('#J_TalkMsgBtn').off('click');
                    $('#J_TalkMsgBtn').on('click', function (e) {
                        if (_This.Data.IsHorn) {
                            _This.Data.IsHorn = false;
                            $('#J_TalkMsgBtn').addClass('active');
                            $('#J_TalkHornBtn').removeClass('active');
                            $('.main-chat-sender').removeClass('main-chat-sender-horn');
                            $('#J_InputTextWord').val('');
                            $("#J_InputTextWord").attr("placeholder", _This.Data.LastPlaceholder);
                            if (_This.Data.LastPlaceholder.substr(0, 1) == '@') $("#J_PrivateCancel").show();
                            _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                            $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                            return;
                        }
                        if (_This.Data.IsFly) {
                            _This.Data.IsFly = false;
                            $('#J_TalkMsgBtn').addClass('active');
                            $('#J_TalkFlyBtn').removeClass('active');
                            $('.main-chat-sender').removeClass('main-chat-sender-fly');
                            $('#J_InputTextWord').val('');
                            $("#J_InputTextWord").attr("placeholder", _This.Data.LastPlaceholder);
                            if (_This.Data.LastPlaceholder.substr(0, 1) == '@') $("#J_PrivateCancel").show();
                            _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                            $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                            return;
                        }
                    });

                    //喇叭按钮
                    $('#J_TalkHornBtn').off('click');
                    $('#J_TalkHornBtn').on('click', function (e) {
                        if (_This.Data.IsHorn) {
                            _ThisPage.Page.Chat.CommonUtils.CancelHorn.Horn();
                            return;
                        }
                        _This.Data.IsHorn = true;
                        _This.Data.IsFly = false;
                        $(".main-chat-sender").removeClass('main-chat-sender-fly').addClass('main-chat-sender-horn');
                        $(this).addClass('active').siblings('.main-chat-tool').removeClass('active');
                        $('#J_InputTextWord').val('');
                        var placeholder = $('#J_InputTextWord').attr('placeholder');
                        if (placeholder.substr(0, 1) == '@') _This.Data.LastPlaceholder = placeholder;
                        var count = parseInt($('#J_TalkHornNum').text());
                        count = count == 0 ? '' : '剩余免费' + count + '条、';
                        $("#J_PrivateCancel").hide();
                        $("#J_InputTextWord").attr("placeholder", "5000金币/条、" + count + "此处输入喇叭内容！");
                        _ThisPage.Page.Chat.Data.Maxlength = 30;
                        $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);

                    });

                    //飞屏按钮
                    $('#J_TalkFlyBtn').off('click');
                    $('#J_TalkFlyBtn').on('click', function (e) {
                        if (_This.Data.IsFly) {
                            _ThisPage.Page.Chat.CommonUtils.CancelHorn.Fly();
                            return;
                        }
                        _This.Data.IsHorn = false;
                        _This.Data.IsFly = true;
                        $(".main-chat-sender").removeClass('main-chat-sender-horn').addClass('main-chat-sender-fly');
                        $(this).addClass('active').siblings('.main-chat-tool').removeClass('active');
                        $('#J_InputTextWord').val('');
                        var placeholder = $('#J_InputTextWord').attr('placeholder');
                        if (placeholder.substr(0, 1) == '@') _This.Data.LastPlaceholder = placeholder;
                        var count = parseInt($('#J_TalkFlyNum').text());
                        count = count == 0 ? '' : '剩余免费 ' + count + ' 条、';
                        $("#J_PrivateCancel").hide();
                        $("#J_InputTextWord").attr("placeholder", "2000金币/条、" + count + "此处输入弹幕内容！");
                        _ThisPage.Page.Chat.Data.Maxlength = 30;
                        $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                    });

                    //关闭 滚屏
                    $('#J_ChatLockScrollBtn').off('click');
                    $('#J_ChatLockScrollBtn').on('click', function () {
                        if (_This.Data.IsLockScroll) {
                            _This.Data.IsLockScroll = !_This.Data.IsLockScroll;
                            $(this).removeClass('main-chat-tool-scroll-disable');
                            $(this).addClass('main-chat-tool-scroll');
                            _This.ChatScrollToBottom();
                        } else {
                            _This.Data.IsLockScroll = !_This.Data.IsLockScroll;
                            $(this).addClass('main-chat-tool-scroll-disable');
                            $(this).removeClass('main-chat-tool-scroll');
                        }
                    });

                    //切换 公聊/私聊
                    $('.main-chat-tool-switch').off('click', 'a');
                    $('.main-chat-tool-switch').on('click', 'a', function (e) {
                        $(this).addClass('main-chat-tool-chatto-active').siblings().removeClass('main-chat-tool-chatto-active');
                        if ($(this).index()) {
                            $('#J_WebChatList').hide();
                            $('#J_WebChatListPrivate').show();
                        } else {
                            $('#J_WebChatList').show();
                            $('#J_WebChatListPrivate').hide();
                        }
                    });

                    //艺人 官方 不限制字数
                    if (!($.CommonMainRoom.RoomUserInfo.RoomAnchor)) {
                        _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                        $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                    }

                    _ThisPage.Page.Chat.FaceEmo.InitPanel();//初始化 普通表情，VIP表情，守护表情，是否显示开通按钮等。
                    // _ThisPage.Page.Chat.InitScrollBar();
                    _ThisPage.Page.Chat.InitLoadWord(_VirtualPath.Static + "/main/js/room.chat.word.txt");

                    //提示进入房间
                    _ThisPage.Page.Chat.RoomEnterNewUserNotify(data);
                    //系统提示
                    _ThisPage.Page.Chat.SysText("<a href='" + _VirtualPath.Main + "activity/2016/firstpay' target='_blank' class='alink-sys'>首次充值赠送超值大礼包！</a><br>聊天中若涉及财产的操作，冒充官方人员，请联系官方客服核实对方身份，谨防受骗！");
                    //游客诱导文字
                    _ThisPage.Page.Chat.GuestText.Init();

                    //登陆状态下，没有绑定手机，显示绑定手机。
                    if (_StateData.IsLogin && !$.CommonMainRoom.RoomUserInfo.IsPhone) {
                        $('#J_InputTextDisable').show();
                        $('#J_MainChatSender').addClass('main-chat-sender-disable');
                        _ThisPage.Page.Chat.Data.isCanSend = false;
                    }
                },
                //初始化 聊天区 滚动条
                InitScrollBar: function () {
                    $("#J_WebChatList").perfectScrollbar();
                    $("#J_WebChatListPrivate").perfectScrollbar();
                    $("#J_GameList").perfectScrollbar();
                    $("#J_EmoJi_Box").perfectScrollbar();
                },
                //加载敏感词
                InitLoadWord: function (url) {
                    if (_ThisPage.Page.Chat.Data.Word.length > 0) return;
                    $.get(url, {}, function (data) {
                            _ThisPage.Page.Chat.Data.Word = data.split("|");
                        },
                        "text"
                    );
                },
                //发送消息事件
                ChatSendEvent: function () {
                    var _This = _ThisPage.Page.Chat;
                    if (!$.CommonMain.LoginCheck()) {
                        return;
                    }
                    if (!_ThisPage.Page.Chat.Data.isCanSend) return;

                    var txt = $("#J_InputTextWord").val().trim();
                    if (!txt) return;

                    //测试消息
                    var re = /\[test:([0-9]*)\]/g;
                    if (re.test(txt)) {
                        _ThisPage.Page.Chat.Data.TestCurrCount = 0;
                        _ThisPage.Page.Chat.Data.TestMaxCount = Number(txt.replace(/\[test:([0-9]*)\]/g, '$1'));
                        clearInterval(_ThisPage.Page.Chat.Data.TestInterval);
                        _ThisPage.Page.Chat.Data.TestInterval = setInterval(_ThisPage.Page.Chat.TestAutoSendMsg, 70);
                        return;
                    }

                    var msgObj = {};
                    msgObj.Private = (_ThisPage.Page.Chat.Data.ChatUser.Receiver) ? _ThisPage.Page.Chat.Data.ChatUser.Private : false;
                    msgObj.PrivateTa = (_ThisPage.Page.Chat.Data.ChatUser.Receiver) ? _ThisPage.Page.Chat.Data.ChatUser.PrivateTa : false;
                    Log.Out("发送消息", msgObj);
                    // //脏话过滤
                    // txt = _ThisPage.Page.Chat.MsgFilter(txt);

                    //喇叭||飞屏
                    if (_This.Data.IsHorn) {
                        $.CommonMainRoom.SocketEmit.Horn(_ThisPage.Page.FlyScreen.Data.HornMode, txt);
                        _ThisPage.Page.FlyScreen.ResetHornFly();
                        return;
                    } else if (_This.Data.IsFly) {
                        $.CommonMainRoom.SocketEmit.Horn(_ThisPage.Page.FlyScreen.Data.FlyScreenMode, txt);
                        _ThisPage.Page.FlyScreen.ResetHornFly();
                        return;
                    }


                    //房间艺人 没加 发言间隔
                    if (!$.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                        //发言时间间隔
                        if (!_ThisPage.Page.Chat.Data.isCanSend) return;
                        var config = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level];
                        if (msgObj.Private && !config.private) {
                            _ThisPage.Page.CommonUitls.Tip("您升级到【3富】即可开启私聊功能！");
                            return;
                        }

                        _ThisPage.Page.Chat.Data.isCanSend = false;
                        clearInterval(_ThisPage.Page.Chat.Data.Interval);
                        var time = config.interval;
                        $("#J_TalkPublishBtn").text(time + "秒");
                        _ThisPage.Page.Chat.Data.Interval = setInterval(function () {
                            time--;
                            $("#J_TalkPublishBtn").text(time + "秒");
                            if (time <= 0) {
                                _ThisPage.Page.Chat.Data.isCanSend = true;
                                clearInterval(_ThisPage.Page.Chat.Data.Interval);
                                $("#J_TalkPublishBtn").text("发送");
                                $("#J_TalkPublishBtn").css({opacity: 1});
                            }
                        }, 1000);
                        //发言长度限制
                        _ThisPage.Page.Chat.Data.Maxlength = config.char;
                        $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                        $("#J_TalkPublishBtn").css({opacity: 0.5});
                    }

                    msgObj.text = txt;
                    msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                    msgObj.User2 = (_ThisPage.Page.Chat.Data.ChatUser.Receiver) ? _ThisPage.Page.Chat.GetMsgUserFormat(_ThisPage.Page.Chat.Data.ChatUser.Receiver) : null;

                    _ThisPage.Page.Chat.Data.MsgObj = msgObj;
                    // _ThisPage.Page.Chat.ChatShowMsg(msgObj);


                    if (msgObj.Private) {
                        $.CommonMainRoom.SocketEmit.Message(txt, msgObj.User2.User_ID, true);
                        Log.Out("私聊", msgObj.User2.User_ID);
                    } else if (msgObj.PrivateTa) {
                        $.CommonMainRoom.SocketEmit.Message(txt, msgObj.User2.User_ID);
                        Log.Out("对他说", msgObj.User2.User_ID);
                    } else {
                        $.CommonMainRoom.SocketEmit.Message(txt);
                        Log.Out("公聊");
                    }
                    //发送完成之后清空输入框
                    $("#J_InputTextWord").val('').focus();
                },
                //获取 聊天 用户数据格式
                GetMsgUserFormat: function (UserData) {
                    var data = {};
                    data.isGuest = UserData.Guest;
                    data.IsAdmin = UserData.IsAdmin;
                    data.IsAnchor = UserData.IsAnchor;
                    data.IsFamily = UserData.IsFamily;
                    data.IsMobile = UserData.IsMobile;
                    data.User_ID = UserData.User_ID;
                    data.Level = UserData.Level;
                    data.AnchorLevel = (data.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID) ? $.CommonMainRoom.RoomAnchorInfo.Level : -1;
                    data.NickName = UserData.NickName;
                    data.RoomAdmin = UserData.RoomAdmin;
                    data.RoomAnchor = UserData.RoomAnchor;
                    data.RoomGuardian = UserData.RoomGuardian;
                    data.RoomGuardianMode = UserData.RoomGuardian_Mode;
                    data.VIP = UserData.VIP;
                    data.EmblemList = (UserData.EmblemList != null) ? UserData.EmblemList : null;
                    return data;//<span class="main-chat-tag-user-badge main-chat-tag-user-badge-lv1"></span>
                },
                //接收消息处理
                ChatServerMsgReceive: function (data) {
                    data.Receiver = data.RoomUserInfo_Receiver;//兼容
                    var msgObj = {};
                    if (data.Private) {
                        msgObj.Private = (data.Private) ? data.Private : false;
                        msgObj.PrivateTa = (data.Sender) ? true : false;
                        msgObj.text = data.Message;
                        msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);
                        msgObj.User2 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                        $("#J_ChatNewMsgTip").addClass('NewMsgRec').show();
                    } else {
                        msgObj.Private = (data.Private) ? data.Private : false;
                        msgObj.PrivateTa = (data.Receiver) ? true : false;
                        msgObj.text = data.Message;
                        msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);
                        msgObj.User2 = (data.Receiver) ? _ThisPage.Page.Chat.GetMsgUserFormat(data.Receiver) : null;
                    }
                    _ThisPage.Page.Chat.ChatShowMsg(msgObj);
                },
                //显示聊天消息
                ChatShowMsg: function (msgObj) {
                    // Log.Out("msgObj", msgObj);
                    var _This = this;
                    var msg = "";

                    //脏话过滤
                    msgObj.text = _ThisPage.Page.Chat.MsgFilter(msgObj.text);

                    if (msgObj.Private) {
                        //私聊
                        msg = getChatText(msgObj.User1, msgObj, true);
                        $("#J_ChatlistinfoPrivate").append(msg);
                        $("#J_Chatlistinfo").append(msg);
                        $("#J_ChatlistinfoPrivate span[data-uid=" + msgObj.User1.User_ID + "]").data('userdata', msgObj.User1);
                        $("#J_ChatlistinfoPrivate span[data-uid=" + msgObj.User2.User_ID + "]").data('userdata', msgObj.User2);
                    } else if (msgObj.PrivateTa) {
                        //对Ta说
                        msg = getChatText(msgObj.User1, msgObj, false);
                        $("#J_Chatlistinfo").append(msg);
                        $("#J_Chatlistinfo span[data-uid=" + msgObj.User1.User_ID + "]").data('userdata', msgObj.User1);
                        $("#J_Chatlistinfo span[data-uid=" + msgObj.User2.User_ID + "]").data('userdata', msgObj.User2);
                    } else {
                        //普通
                        if(msgObj.User1.RoomGuardian){
                            msg += '<li class="main-chat-item main-chat-item-guard">'
                        }else {
                            msg += '<li class="main-chat-item">'
                        }
                        msg += this.CommonUtils.GetUserName(msgObj.User1, true);
                        msg += '<div class="main-chat-message"><span class="main-chat-content">' + getUserMsgText(msgObj.User1, msgObj.text) + '</span></div>';
                        msg += '</li>';
                        $("#J_Chatlistinfo").append(msg);
                        $("#J_Chatlistinfo span[data-uid=" + msgObj.User1.User_ID + "]").data('userdata', msgObj.User1);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();

                    //开播时 弹幕
                    if ($.CommonMainRoom.RoomInfo.Live) {
                        var barrage = {
                            text: msgObj.text,
                            userInfo: msgObj.User1,
                            path: _VirtualPath,
                            isSelf: (msgObj.User1.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID) ? true : false
                        };
                        onJsToAs({type: "BarrageAdd", data: barrage});
                    }

                    //聊天区文字格式
                    function getChatText(UserData, msgObj, isPrivate) {
                        var msg = '';
                        var targetText = isPrivate ? ' 悄悄对 ' : ' 对 ';
                        if (msgObj.User1.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID) {
                            //我对谁
                            msg =   '<li class="main-chat-item">';
                            msg +=  '<div class="main-chat-userinfo">' +
                                    '<span class="chat-board-me">我</span><span class="chat-board-to">' + targetText + '</span>' +
                                    '<span title="'+msgObj.User2.NickName+'" data-uid="'+msgObj.User2.User_ID+'" class="chat-board-nickname">'+msgObj.User2.NickName+'</span> 说'+
                                    '</div>';
                            msg += '<div class="main-chat-message">';
                            msg += '<span class="main-chat-content">' + _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, msgObj.text) + '</span>';
                            msg += '</div>';
                            msg += '</li>';
                        } else if (msgObj.User2.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID) {
                            //谁对我
                            msg =   '<li class="main-chat-item">';
                            msg +=  '<div class="main-chat-userinfo">' +
                                    '<span title="'+msgObj.User1.NickName+'" data-uid="'+msgObj.User1.User_ID+'" class="chat-board-nickname">'+msgObj.User1.NickName+'</span>'+
                                    '<span class="chat-board-to">' + targetText + '</span><span class="chat-board-me">我</span> 说' +
                                    '</div>';
                            msg += '<div class="main-chat-message">';
                            msg += '<span class="main-chat-content">' + _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, msgObj.text) + '</span>';
                            msg += '</div>';
                            msg += '</li>';
                        } else {
                            //谁对谁
                            msg = '<li class="main-chat-item">';
                            msg += '<div class="main-chat-userinfo"><span class="chat-board-nickname" data-uid="' + msgObj.User1.User_ID + '">' + msgObj.User1.NickName + '</span><span class="chat-board-to"> 对 </span>';
                            msg += '<span class="chat-board-nickname" data-uid="' + msgObj.User2.User_ID + '">' + msgObj.User2.NickName + '</span> 说</div>';
                            msg += '<div class="main-chat-message">';
                            msg += '<span class="main-chat-content">' + _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, msgObj.text) + '</span>';
                            msg += '</div>';
                            msg += '</li>';
                        }
                        return msg;
                    }

                    //根据 vip 守护 对文字进行 加颜色 表情转义图片
                    function getUserMsgText(UserData, MessageText) {
                        var msg = "";
                        if (UserData.VIP) {
                            msg += _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, MessageText);
                        } else if (UserData.RoomGuardian) {
                            msg += _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, MessageText);
                        } else {
                            msg += _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, MessageText);
                        }
                        return msg;
                    }
                },
                //进房提示语
                RoomEnterNewUserNotify: function (data) {
                    if (data.MountsInfo != null) {
                        if (_ThisPage.Page.Gift.Data.isEffectOn) {
                            //显示 座驾效果
                            data.UserInfo = data.RoomUserInfo;
                            //年守护 修改显示动画时间
                            if (data.MountsInfo.id == "Guardian-YEAR") {
                                data.MountsInfo.EffectDuration = 6000;
                            }
                            // GiftEffectFactory.ShowMount(data, "mount");
                        }
                    }
                    var MountsInfo = data.MountsInfo;
                    var AnchorInfo = $.CommonMainRoom.RoomAnchorInfo;
                    var UserInfo = data.RoomUserInfo;

                    var _Path = UserInfo.RoomAnchor ? "anchor/" : "user/";
                    var _Level = UserInfo.RoomAnchor ? AnchorInfo.Level : UserInfo.Level;

                    if (MountsInfo != null || UserInfo.RoomGuardian) {
                        //欢迎座骑
                        var msg1 = '<li class="main-chat-item main-chat-item-mount-enter">' +
                            this.CommonUtils.GetUserName(UserInfo, false) +
                            '<img title="' + MountsInfo.Name + '" alt="' + MountsInfo.Name + '" src="' + _VirtualPath.Static + '/main/image/mount/car' + MountsInfo.id + '.png" alt="" class="chat-board-mount">' +
                            '</div>' +
                            '<div class="main-chat-message">' +
                            '<span class="main-chat-content">乘坐豪华座驾<span class="board-text"> ' + MountsInfo.Name + ' </span>进场了！列队欢迎～</span>' +
                            '</div>' +
                            '</li>';
                        $("#J_Chatlistinfo").append(msg1);
                        //显示座骑显示
                        if (_ThisPage.Page.Gift.Data.isEffectOn) {
                            _ThisPage.Page.CommonUitls.ShowMounts.AddData({UserInfo: UserInfo, MountsInfo: MountsInfo, Path: _VirtualPath});
                        }
                    } else {
                        //欢迎用户
                        var msg2 = '<li class="main-chat-item main-chat-item-enter">' +
                            this.CommonUtils.GetUserName(UserInfo, false) +
                            '<div class="main-chat-message">' +
                            '<span class="main-chat-content">进入直播间！</span>' +
                            '</div>' +
                            '</li>';

                        //游客进入
                        var guestinfo=' <p>欢迎' + this.CommonUtils.GetUserName(UserInfo, false) + '进入直播间</p>';

                        if(UserInfo.Guest)
                        {
                            clearTimeout(_ThisPage.Page.Chat.Data.GuestEnterTempTime);
                            $("#J_ChatGuest").css({opacity:1});
                            $("#J_ChatGuest").show();
                            $("#J_GuestEnter").html(guestinfo);
                            $("#J_ChatContainer").animate({paddingBottom:"39px"}, 200,function(){
                                _ThisPage.Page.Chat.ChatScrollToBottom();
                            });
                            _ThisPage.Page.Chat.Data.GuestEnterTempTime = setTimeout(function () {
                                $("#J_ChatGuest").animate({opacity:0}, 200, function () {
                                    $("#J_ChatGuest").hide();
                                    $("#J_ChatContainer").animate({paddingBottom:"5px"}, 200);
                                });
                            }, 3000);
                        }
                        else
                        {
                            $("#J_Chatlistinfo").append(msg2);
                            $("#J_Chatlistinfo span[data-uid=" + UserInfo.User_ID + "]").data('userdata', UserInfo);
                        }
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();

                },
                //操作提示语
                OutText: function (data) {
                    var User1 = data.User1;
                    var User2 = data.User2;
                    var Text = data.Text;
                    var msg = '';
                    msg += '<li class="main-chat-item">'
                    msg += this.CommonUtils.GetUserName(User1);
                    msg += '<div class="main-chat-message">';
                    Text = Text.replaceAll("{User1}", User1.NickName);
                    Text = Text.replaceAll("{User2}", User2.NickName);
                    msg += '<span class="main-chat-content">' + Text + '</span>';
                    msg += '</div>';
                    msg += '</li>';
                    $("#J_Chatlistinfo").append(msg);
                    if (!User1.Guest) {
                        $("#J_Chatlistinfo span[data-uid=" + User1.User_ID + "]").data('userdata', User1);
                    }
                    if (!User2.Guest) {
                        $("#J_Chatlistinfo span[data-uid=" + User2.User_ID + "]").data('userdata', User2);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //系统提示
                SysText: function (text) {
                    var msg = '<li class="main-chat-item main-chat-item-system">' +
                        '<div class="main-chat-userinfo">' +
                        '<div class="main-chat-tags">' +
                        '<span class="main-chat-tag-user-official"></span>' +
                        '</div>' +
                        '<span class="chat-board-nickname">系统消息</span>' +
                        '</div>' +
                        '<div class="main-chat-message">' +
                        '<span class="main-chat-content">' + text + '</span>' +
                        '</div>' +
                        '</li>';
                    $("#J_Chatlistinfo").append(msg);
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //送礼提示
                GiftTip: function (data) {
                    var msg = '<li class="main-chat-item main-chat-item-send">';
                    msg += _ThisPage.Page.Chat.CommonUtils.GetUserName(data.UserInfo);
                    if (!data.RoomAnchor) msg += '<div class="chat-board-cpr"><span class="chat-board-to">对</span><span class="chat-board-nickname">' + data.UserInfo_Gift.NickName + '</span>';
                    msg += '<div class="main-chat-message">';
                    msg += '送 <span class="main-chat-content">' + data.GiftName + '<img src="' + _VirtualPath.Static + 'main/image/room/gift/' + data.Gift_ID + '.png" alt="" class="main-chat-sys-gift"><span class="main-chat-sys-gift-x">x</span><span class="main-chat-sys-gift-num">' + data.Num + '</span></span>';
                    msg += '</div>';
                    msg += '</li>';
                    $("#J_Chatlistinfo").append(msg);
                    $("#J_Chatlistinfo span[data-uid=" + data.UserInfo.User_ID + "]").data('userdata', data.UserInfo);
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //意外中奖
                GiftAwards: function (data) {
                    _ThisPage.Page.Chat.SysText('恭喜<span title="'+data.UserInfo.NickName+'" data-uid="'+data.UserInfo.User_ID+'" class="chat-board-nickname"> '+data.UserInfo.NickName+' </span>在送礼物的过程中，意外获得了<span class="main-chat-coin-num">' + data.Amt + ' </span>金币的奖励!</span>');
                },
                //抽奖中奖信息
                GiftLuckDraw: function (data) {
                    var html = '<li class="main-chat-item main-chat-item-gainprize">' +
                        '<div class="main-chat-userinfo">' +
                        '<span class="chat-board-nickname txt-ellipsis">'+data.RoomUserInfo.NickName+'</span>（<a href="/room/'+data.RoomAnchorInfo.RoomID+'" target="_blank" class="chat-board-nickname anchor-name txt-ellipsis">'+data.RoomAnchorInfo.NickName+'</a>直播间）' +
                        '</div>' +
                        '<div class="main-chat-message">' +
                        '<span class="main-chat-content">通过 <a class="chat-board-nickname txt-ellipsis" data-game="game-goldegg">砸蛋游戏</a> 获得<span class="gain-total">'+data.PoundEggWinningList[0].Name+'</span>的奖励</span>' +
                        '<img src="'+_VirtualPath.Static + 'main/template/imax/image/board-prize-tip.png" alt="baojiang" class="board-prize-tip">' +
                        '</div>' +
                        '</li>';

                    if('ROOM' == data.PoundEggWinningList[0].Inform){
                        html = '<li class="main-chat-item main-chat-item-gainprize-egg">' +
                            '<div class="main-chat-userinfo">' +
                            '<img src="'+_VirtualPath.Static + 'main/template/imax/image/board-prize-egg.png" alt="" class="board-prize-egg">' +
                            '<span class="chat-board-nickname">砸蛋中奖消息</span>' +
                            '</div>' +
                            '<div class="main-chat-message">' +
                            '<span class="main-chat-content">恭喜 <a class="chat-board-nickname txt-ellipsis">'+data.RoomUserInfo.NickName+'</a> 获得 <span class="gain-total">'+data.PoundEggWinningList[0].Name+'</span> 的奖励</span>' +
                            '</div>' +
                            '</li>';
                    }
                    $("#J_Chatlistinfo").append(html);
                    // $("#J_Chatlistinfo span[data-uid=" + data.RoomUserInfo.User_ID + "]").data('userdata', data.RoomUserInfo);
                    _ThisPage.Page.Chat.ChatScrollToBottom();

                    _ThisPage.Page.Game.PoundEgg.Init();
                },
                //违规警告
                WarningSet: function (data) {
                    var WarningData = data.WarningInfo;
                    var kfStr = (WarningData.Integral>0) ? "， 扣 "+WarningData.Integral+" 分" : "";//扣分文字
                    if(WarningData.operation >0) kfStr += "，" + (WarningData.operation==1) ? "结束直播" : "冻结房间";//操作
                    var html = '<li class="main-chat-item sys-warn">' +
                        '<div class="chat-content">' +
                        '<div class="main-chat-userinfo">' +
                        '<div class="main-chat-tags">' +
                        '<span class="main-chat-tag-user-official"></span>' +
                        '</div>' +
                        '<span class="chat-board-nickname">秩序监管：'+WarningData.Type+kfStr+'</span>' +
                        '</div>' +
                        '<div class="main-chat-message">' +
                        '<span class="main-chat-content">提醒艺人，'+WarningData.Remark+'！</span>' +
                        '</div>' +
                        '</div>' +
                        '</li>';
                    $("#J_Chatlistinfo").append(html);
                    $("#J_ChatlistinfoPrivate").append(html);
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //用户升级提示
                UserLevel: function (data) {

                },
                //显示给游客的诱导文字
                GuestText: {
                    Data: {
                        Msg: [
                            ["你是新来的吧，有什么想问我吗？", "来了这么久都不理人家，人家好难受..."],
                            ["听说有些艺人晚上偷偷跳舞，你说我晚上来跳舞会不会被巡查抓到？", "怎么这么久都不回复我呢？哼，不理你啦！"],
                            ["怎么不理我？", "跟我聊聊呗^_^"],
                            ["你好！", "在吗？"],
                        ],
                        MsgIndex: 0
                    },
                    Init: function () {
                        if (!$.CommonMainRoom.RoomInfo.Live) return;
                        if (_StateData.IsLogin) return;

                        var index = _ThisPage.Page.Chat.GuestText.Data.MsgIndex = Math.floor(_ThisPage.Page.Chat.GuestText.Data.Msg.length * Math.random());
                        var anchorInfo = $.CommonMainRoom.RoomAnchorInfo;
                        anchorInfo.User_ID = $.CommonMainRoom.RoomAnchorInfo.RoomID;

                        setTimeout(function () {
                            _ThisPage.Page.Chat.GuestText.Out(anchorInfo, _ThisPage.Page.Chat.GuestText.Data.Msg[index][0]);
                        }, 3000);
                        setTimeout(function () {
                            _ThisPage.Page.Chat.GuestText.Out(anchorInfo, _ThisPage.Page.Chat.GuestText.Data.Msg[index][1]);
                        }, 33000);
                    },
                    Out: function (anchorInfo, text) {
                        var msg = '<li class="main-chat-item">' +
                            '<div class="main-chat-userinfo">' +
                            '<span title="'+anchorInfo.NickName+'" data-uid="'+anchorInfo.User_ID+'" class="chat-board-nickname">'+anchorInfo.NickName+'</span>' +
                            '<span class="chat-board-to"> 悄悄对 </span><span class="chat-board-me">我</span>' +
                            '</div>' +
                            '<div class="main-chat-message">' +
                            '<span class="main-chat-content">' + text + '</span>' +
                            '</div>' +
                            '</li>';
                        $("#J_Chatlistinfo").append(msg);
                        _ThisPage.Page.Chat.ChatScrollToBottom();
                    }
                },


                //始终保持在底部
                ChatScrollToBottom: function () {
                    if ($("#J_Chatlistinfo").children().length > _ThisPage.Page.Chat.Data.MsgMaxCount) {
                        $("#J_Chatlistinfo").children()[0].remove();
                    }
                    if ($("#J_ChatlistinfoPrivate").children().length > _ThisPage.Page.Chat.Data.MsgMaxCount) {
                        $("#J_ChatlistinfoPrivate").children()[0].remove();
                    }

                    if (_ThisPage.Page.Chat.Data.IsLockScroll) return;
                    $("#J_WebChatList").scrollTop($('#J_Chatlistinfo').height());
                    $("#J_WebChatListPrivate").scrollTop($('#J_ChatlistinfoPrivate').height());
                },
                //公聊 私聊 TAB界面切换 index 0是公聊 1私聊
                ChatSelectTab: function (index) {
                    var tabArr = ["#J_PublicChatTabBtn", "#J_PrivateChatTabBtn"];
                    $(tabArr[index]).addClass('on').siblings().removeClass('on');
                    $(".WebChatList").hide().eq(index).show();
                    // Log.Out("ChatSelectTab",index);
                    if (0 == index) {
                        // _ThisPage.Page.Chat.Data.ChatUser.id = 0;
                        _ThisPage.Page.Chat.Data.ChatUser.Private = false;
                        _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = false;
                        // _ThisPage.Page.Chat.Data.ChatUser.Receiver = null;
                        $("#J_InputTextWord").attr("placeholder", "双手打字，以示清白~");
                    } else if (1 == index) {
                        $("#J_ChatNewMsgTip").removeClass('NewMsgRec').fadeOut();
                        if (_ThisPage.Page.Chat.Data.ChatUser.Receiver) {
                            _ThisPage.Page.Chat.Data.ChatUser.Private = true;
                            _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = true;
                            $("#J_InputTextWord").attr("placeholder", "@ 对 " + _ThisPage.Page.Chat.Data.ChatUser.Receiver.NickName + " 悄悄说");
                        }
                    }
                },
                //关闭表情选择面板
                ChatCloseFaceEmoPanel: function () {
                    $('#J_FaceEmoLayer').hide();
                    $(window).off("click");
                    $("#J_InputTextWord").focus();
                },
                //文字 消息 过滤
                MsgFilter: function (txt) {
                    if (_ThisPage.Page.Chat.Data.Word.length > 0) {
                        _ThisPage.Page.Chat.Data.Word.forEach(function (value) {
                            txt = _.replace(txt, value, _.repeat('*', value.length));
                            txt = txt.replaceAll(value, _.repeat('*', value.length));
                            // var starLen = _.repeat('*', value.length);
                            // var keyStr = value.split("").join('.{0,3}');
                            // var regexp = new RegExp(keyStr, "g");
                            // txt = txt.replace(regexp, starLen);
                        });
                    }

                    txt = filterUighurTibetan(txt);
                    txt = filterQQ(txt);

                    //过滤 维语藏语
                    function filterUighurTibetan(str) {
                        var s = "";
                        for (var i = 0; i < str.length; i++) {
                            var str1 = str.substr(i, 1);
                            var ascii = str1.charAt(i).charCodeAt();
                            var isUT = IsUighurTibetan(str1);
                            if (isUT) {
                                s += "*";
                            } else {
                                s += str1;
                            }
                        }
                        return s;
                    }
                    //是否 维语藏语
                    function IsUighurTibetan(char) {
                        var start = 1000;
                        var end = 5000;
                        var n = char.charAt().charCodeAt();
                        // Log.Out("ASCII", [char, n]);
                        return (n >= start && n <= end) ? true : false;
                    }

                    //QQ号码
                    function filterQQ(str){
                        var QQ_patt = new RegExp('([0-9]|\s| ){6,12}', "g");
                        return str.replace(QQ_patt, "*");
                    }

                    return txt;
                },
                //聊天区 表情符号
                FaceEmo: {
                    //初始化表情面板
                    InitPanel: function () {
                        $(".main-emoji-cont").perfectScrollbar();
                        //点击 打开表情面板按钮
                        $("#J_TalkFaceBtn").off('click');
                        $("#J_TalkFaceBtn").on('click', function (event) {
                            event.preventDefault();
                            if ($('#J_FaceEmoLayer').is(':hidden')) {
                                $('#J_FaceEmoLayer').show();
                                setTimeout(function () {
                                    $(window).off("click");
                                    $(window).on("click", function (e) {
                                        if (_ThisPage.Page.Chat.Data.isMouseAreaFaceEmo) return;
                                        _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                                    });
                                }, 10);
                            } else {
                                _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                            }
                        });
                        $('#J_FaceEmoLayer').on("mouseover", function () {
                            _ThisPage.Page.Chat.Data.isMouseAreaFaceEmo = true;
                        });
                        $('#J_FaceEmoLayer').on("mouseout", function () {
                            _ThisPage.Page.Chat.Data.isMouseAreaFaceEmo = false;
                        });
                        //表情类型 TAB 切换
                        $('#J_FaceTab').off('click');
                        $('#J_FaceTab').on('click', 'a', function (event) {
                            var index = $(this).index();
                            $(this).addClass('active').siblings().removeClass('active');
                            $('.main-emoji-cont .main-emoji-panel').eq(index).addClass('main-emoji-panel-active').siblings('.main-emoji-panel').removeClass('main-emoji-panel-active');
                            $(".main-emoji-cont").scrollTop(0);
                        });

                        //选择具体某个表情
                        $(".main-emoji-panel").off('click');
                        $(".main-emoji-panel").on('click', 'li', function (event) {
                            var _val = $(this).find('img').attr('alt');
                            var tempS = $("#J_InputTextWord").val() + "[" + _val + "]";
                            if (!$.CommonMainRoom.RoomUserInfo.RoomAnchor && tempS.length > _ThisPage.Page.Chat.Data.Maxlength) {
                                _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                                return;
                            }
                            if(_StateData.IsLogin) $("#J_InputTextWord").val($("#J_InputTextWord").val() + "[" + _val + "]");
                            _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                        });

                        var UserInfo = $.CommonMainRoom.RoomUserInfo;
                        var _Emoji = '';
                        var _EmoVip = '';
                        var _EmoGuard = '';
                        for (var i = 1; i <= 56; i++) {
                            _Emoji += '<li><a href="javascript:;" class="icon-xiutv-emoji" data-txt="用户表情" data-key="' + i + '"><img src="' + _VirtualPath.Static + 'main/image/emo/emoji/emoji_' + i + '.png" alt="f' + i + '"></a></li>';

                            if (i <= 24) {
                                _EmoVip += '<li><a href="javascript:;" class="icon-xiutv-emoji" data-txt="VIP表情" data-key="' + i + '"><img src="' + _VirtualPath.Static + 'main/image/emo/common/e' + i + '.png" alt="v' + i + '"></a></li>';
                            }
                            if (i <= 10) {
                                _EmoGuard += '<li><a href="javascript:;" class="icon-xiutv-emoji" data-txt="守护表情" data-key="' + i + '"><img src="' + _VirtualPath.Static + 'main/image/emo/guard/e' + i + '.png" alt="g' + i + '"></a></li>';
                            }
                        }
                        $("#J_EmoJi").html(_Emoji);
                        $("#J_EmoVip").html(_EmoVip);
                        $("#J_EmoGuard").html(_EmoGuard);

                        //检测表情权限
                        if (!UserInfo.VIP) {
                            var _html = '<div class="main-emoji-panel-locker">' +
                                '<a href="/mall/vip/" target="_blank" class="emoji-btn-now" >开通会员</a>' +
                                '</div>'
                            $("#J_EmoVip").append(_html);
                        }
                        if (!UserInfo.RoomGuardian) {
                            var _html = '<div class="main-emoji-panel-locker">' +
                                '<a href="javascript:;" class="emoji-btn-now"  id="J_UserBuyGuardBtn">开通守护</a>' +
                                '</div>'
                            $("#J_EmoGuard").append(_html);
                        }
                    },
                    //表情替换规则
                    FaceEscape: function (UserInfo, text) {
                        function replaceEmo(text) {
                            for (var i = 1; i <= 56; i++) {
                                var key = '[f' + i + ']';
                                text = text.replaceAll(key, '<img src="' + _VirtualPath.Static + 'main/image/emo/emoji/emoji_' + i + '.png"  class="chat-emoticon" />');
                            }
                            return text;
                        }

                        function replaceEmoVIP(text) {
                            for (var i = 1; i <= 24; i++) {
                                var key = '[v' + i + ']';
                                text = text.replaceAll(key, '<img src="' + _VirtualPath.Static + 'main/image/emo/common/e' + i + '.png" class="chat-emoticon" />');
                            }
                            return text;
                        }

                        function replaceEmoGuard(text) {
                            for (var i = 1; i <= 10; i++) {
                                var key = '[g' + i + ']';
                                text = text.replaceAll(key, '<img src="' + _VirtualPath.Static + 'main/image/emo/guard/e' + i + '.png"  class="chat-emoticon"/>');
                            }
                            return text;
                        }

                        text = text.replace(/\&/g, '&amp;');
                        text = text.replace(/\</g, '&lt;');
                        text = text.replace(/\>/g, '&gt;');
                        text = text.replace(/\"/g, '&quot;');
                        text = text.replace(/\'/g, '&#039;');
                        // 循环
                        text = replaceEmo(text);
                        if (UserInfo.VIP) text = replaceEmoVIP(text);
                        if (UserInfo.RoomGuardian) text = replaceEmoGuard(text);
                        return text;
                    }
                },
            },
            /**
             * 礼物功能
             */
            Gift: {
                Data: {
                    GiftId: 58, // 当前选中的礼物ID 默认黄瓜
                    GiftListIndex: 0, //当前选中的礼物列表索引
                    GiftNum: 1, // 当前选中的礼物数量 默认1
                    TargetUserId: 0, //赠送目标ID
                    // sending:false, //是否 正在赠送中
                    isEffectOn: true, //是否 效果 开启
                    GiftSendBtnTimeout: 0, //赠送按钮动画
                    GiftSendBtnInterval: 0, //赠送按钮动画
                    IntervalNum: 0, //赠送按钮动画

                    GiftTag: ["Hot", "Package"], //当前礼物类型 标签
                    CurrTag: null, //当前 标签 类型

                    GiftDefaultShowIndex: 0, //礼物列表默认 显示礼物 索引
                    PackageDefaultShowIndex: 0 //包裹列表默认 显示 索引
                },
                //初始化
                Init: function (data) {
                    var _This = this;
                    _ThisPage.Page.Gift.Data.sending = false;
                    //初始化 礼物列表
                    _ThisPage.Page.Gift.InitGiftList(0, 0);
                    _ThisPage.Page.Gift.InitGiftTabEvent();
                    //包裹
                    // _ThisPage.Page.Gift.ShowPackage();

                    //初始化 赠送对象人 ID,礼物数量
                    _ThisPage.Page.Gift.Data.GiftNum = parseInt($("#J_GiftInputNum").val()); //默认礼物 数量
                    _ThisPage.Page.Gift.Data.TargetUserId = $.CommonMainRoom.RoomAnchorInfo.RoomID; //房间ID就是艺人ID
                    // $("#J_GiftReceiveUser").val($.CommonMainRoom.RoomAnchorInfo.NickName); //默认礼物接受人 昵称
                    //添加到赠送对象人 列表
                    // _ThisPage.Page.Gift.AddGiftReceiveUserList({
                    //     User_ID:$.CommonMainRoom.RoomAnchorInfo.RoomID,
                    //     NickName:$.CommonMainRoom.RoomAnchorInfo.NickName
                    // });

                    //初始化房间 送礼历史记录列表【数据未定】
                    // GiftEffectFactory.GiftHistoryListRoomInit( $("#J_GiftHistoryListDiv"), $("#J_GiftHistoryList"), data);
                    // $("#J_GiftHistoryListDiv").perfectScrollbar();

                    $(".histroy-content-wrap").perfectScrollbar();

                    $("#J_HistroyIcon").on('click', function (event) {
                        event.preventDefault();
                        /* Act on the event */
                        var elem = $('#J_ModalGiftHistoryList');
                        dialog({
                            align: 'top right',
                            title: '礼物历史记录',
                            content: elem,
                            id: 'ID_Modal_10005',
                            padding: '0',
                        }).show($('#J_HistroyIcon')[0]);
                    });

                    if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                        $('.main-gift-histroy').show();
                    }
                },
                //初始化礼物按钮事件
                InitGiftTabEvent: function () {
                    var _This = this;
                    //切换 礼物/包裹 TAB
                    $("#J_GiftTab").off('click', 'a');
                    $("#J_GiftTab").on('click', 'a', function (event) {
                        var index = $(this).index();
                        if (index == 1 && !$.CommonMain.LoginCheck()) {
                            return;
                        }
                        $(this).addClass('active').siblings().removeClass('active');
                        if (index == 1) {
                            $('#J_GiftPanel').hide();
                            $('#J_GiftPackagePanel').show();
                            _ThisPage.Page.Gift.Data.CurrTag = "Package";
                            _ThisPage.Page.Gift.ShowPackage();
                        } else {
                            $('#J_GiftPanel').show();
                            $('#J_GiftPackagePanel').hide();
                            _ThisPage.Page.Gift.Data.CurrTag = "Hot";
                            var GiftArrData = _.filter(_PageData.Commodity.Gift.Data, {Status:0, Tag: ["Hot"]})[_ThisPage.Page.Gift.Data.GiftDefaultShowIndex];
                            var GiftData = {
                                GiftId: parseInt(GiftArrData.id),
                                GiftName: GiftArrData.Name,
                                Index: _ThisPage.Page.Gift.Data.GiftDefaultShowIndex
                            };
                            Log.Out("GiftData ===--->>>", GiftData);
                            _ThisPage.Page.Gift.GiftCountShow(GiftData);
                        }
                    });
                    //礼物数量过滤
                    $("#J_GiftInputNum").keyup(function (event) {
                        var _val = $(this).val().replace(/[^0-9]\D*$/, "");
                        $(this).val(_val);
                        _ThisPage.Page.Gift.Data.GiftNum = _val;
                    });
                    //点击赠送按钮
                    $("#J_GiftGiveBtn").off('click');
                    $("#J_GiftGiveBtn").on('click', function (event) {
                        if (!$.CommonMain.LoginCheck()) return;
                        if (_ThisPage.Page.Gift.Data.sending) return;
                        if (!_ThisPage.Page.Gift.Data.GiftId || _ThisPage.Page.Gift.Data.GiftId == 0) {
                            _ThisPage.Page.CommonUitls.Tip("请先选择一个礼物!");
                            return;
                        }
                        var BuyMode = (_ThisPage.Page.Gift.Data.CurrTag == "Package") ? 2 : 1; //1只购买 2只包裹
                        // _ThisPage.Page.Gift.Data.TargetUserId = '';

                        Log.Out("赠送礼物==========》", [
                            "GiftId:" + _ThisPage.Page.Gift.Data.GiftId,
                            "GiftNum:" + _ThisPage.Page.Gift.Data.GiftNum,
                            "TargetUserId:" + _ThisPage.Page.Gift.Data.TargetUserId,
                            "BuyMode:" + BuyMode]);
                        _ThisPage.Page.Gift.Data.sending = true;
                        $.CommonMainRoom.SocketEmit.Gift(_ThisPage.Page.Gift.Data.GiftId, _ThisPage.Page.Gift.Data.GiftNum, _ThisPage.Page.Gift.Data.TargetUserId, BuyMode);

                    });
                    //点击 更多礼物小三角按钮
                    $("#J_MoreGifts").off('click');
                    $("#J_MoreGifts").on('click', function (event) {
                        event.preventDefault();
                        if (_ThisPage.Page.Gift.Data.CurrTag == "Package") {
                            return;
                        }
                        if (!$("#J_GiftList .main-gift-content").hasClass('extend')) {
                            Show_MoreGiftList();
                            setTimeout(function () {
                                $(window).off('click');
                                $(window).on('click', Hide_MoreGiftList);
                            }, 10);
                        } else {
                            Hide_MoreGiftList();
                        }

                    });
                    function Show_MoreGiftList() {
                        //展出 减去上下16padding
                        var RowCount = Math.ceil($("#J_GiftPanel ul li").length / 6) * 56 - 12;
                        $("#J_GiftList .main-gift-content").addClass('extend');
                        $("#J_GiftPanel ul").css({
                            "top": "0"
                        });
                        $("#J_GiftPanel").css({
                            "height": RowCount + "px"
                        });
                    }

                    function Hide_MoreGiftList() {
                        //缩回
                        $(window).off('click');
                        var posTop = $("#J_GiftPanel").data('posTop') || 3;
                        $("#J_GiftList .main-gift-content").removeClass('extend');
                        $("#J_GiftPanel").removeAttr('style');
                        $("#J_GiftPanel ul").css({
                            "top": (-posTop) + "px"
                        });
                    }


                    //点击 礼物 ITEM
                    $("#J_GiftPanel, #J_GiftPackagePanel").off('click', 'li');
                    $("#J_GiftPanel, #J_GiftPackagePanel").on('click', 'li', function (event) {
                        event.preventDefault();
                        $(this).addClass('active').siblings().removeClass('active');

                        //设置默认索引（中奖更新包裹会有用）
                        var index = $(this).index();
                        if (_ThisPage.Page.Gift.Data.CurrTag == "Package") {
                            _ThisPage.Page.Gift.Data.PackageDefaultShowIndex = index;
                        } else {
                            //菜单坐标控制
                            var top = $(this).position().top + 3;
                            $("#J_GiftPanel").data('posTop', top);
                            $("#J_GiftPanel ul").css({
                                "top": -top
                            });
                            $("#J_GiftList .main-gift-content").removeClass('extend');
                            $("#J_GiftPanel").removeAttr('style');

                            _ThisPage.Page.Gift.Data.GiftDefaultShowIndex = index;
                        }
                        //更新 礼物ITEM提示
                        var GiftData = {
                            GiftId: parseInt($(this).attr("data-id")),
                            GiftName: $(this).attr("data-name")
                        };
                        _ThisPage.Page.Gift.GiftCountShow(GiftData);
                    });
                    //礼物ITEM提示
                    $('#J_GiftPanel, #J_GiftPackagePanel').off('mouseenter', 'li');
                    $('#J_GiftPanel, #J_GiftPackagePanel').on('mouseenter', 'li', function () {
                        var po = $(this).position();
                        var GiftInfo = {
                            id: $(this).attr('data-id'),
                            name: $(this).attr('data-name'),
                            Price: $(this).attr('data-Price'),
                            Intro: $(this).attr('data-Intro'),
                            StreamerNum: $(this).attr('data-Streamer-Num'),
                            StreamerLevel: $(this).attr('data-Streamer-Level')
                        };
                        if (GiftInfo.id == undefined) return;
                        $('#J_GiftPanelTip_GiftImg').attr('src', _VirtualPath.Static + 'main/image/room/gift/' + GiftInfo.id + '.png');
                        $('#J_GiftPanelTip_GiftName').text(GiftInfo.name);
                        $('#J_GiftPanelTip_GiftPrice').text(GiftInfo.Price + '币');
                        $('#J_GiftPanelTip_GiftDesc').text('一次赠送' + GiftInfo.StreamerNum + '触发' + GiftInfo.StreamerLevel + '星流光');
                        if (GiftInfo.Intro != null && GiftInfo.Intro != '') {
                            $('#J_GiftPanelTip_GiftIntro').show();
                            $('#J_GiftPanelTip_GiftIntro').text(GiftInfo.Intro);
                        } else {
                            $('#J_GiftPanelTip_GiftIntro').hide();
                        }

                        if ($("#J_GiftList .main-gift-content").hasClass('extend')) {
                            $('#J_GiftPanelTip').css({
                                left: (po.left + 7) + 'px',
                                top: (po.top - $("#J_GiftPanel").height()) - $('#J_GiftPanelTip').height() + 40 + 'px'
                            }).show();
                        } else {
                            $('#J_GiftPanelTip').css({
                                left: (po.left + 7) + 'px',
                                top: (-77 - $('#J_GiftPanelTip').height() + 60) + 'px'
                            }).show();
                        }

                    });
                    $('#J_GiftPanel, #J_GiftPackagePanel').off('mouseleave', 'li');
                    $('#J_GiftPanel, #J_GiftPackagePanel').on('mouseleave', 'li', function () {
                        $('#J_GiftPanelTip').hide();
                    });

                    //点击 选择礼物 数量按钮
                    $('#J_OptionList').off('click', 'li');
                    $('#J_OptionList').on('click', 'li', function () {
                        $(this).addClass('active').siblings().removeClass('active');
                        _This.Data.GiftNum = $(this).data('num');
                        $('#J_GiftInputNum').val(_This.Data.GiftNum);
                    });
                    $("#J_NumSelect").off('click');
                    $("#J_NumSelect").on('click', function (event) {
                        event.preventDefault();
                        if (!$(".main-gift-submit").hasClass('extend')) {
                            Show_GiftNumSelect();
                        } else {
                            Hide_GiftNumSelect();
                        }
                    });
                    //显示 选择礼物数量
                    function Show_GiftNumSelect() {
                        if ($(".main-gift-submit").hasClass('extend')) return;

                        $(".main-gift-submit").addClass('extend');
                        var height = $("#J_OptionList ul").height();
                        $("#J_OptionList").css({
                            "height": height
                        });
                        setTimeout(function () {
                            $(window).off('click');
                            $(window).on('click', Hide_GiftNumSelect);
                        }, 10);
                    }

                    //隐藏 选择礼物数量
                    function Hide_GiftNumSelect() {
                        if (!$(".main-gift-submit").hasClass('extend')) return;
                        $(window).off('click');
                        $(".main-gift-submit").removeClass('extend');
                        $("#J_OptionList").css({
                            "height": "0"
                        });
                    }
                },
                //初始化礼物列表
                InitGiftList: function (index, GiftListIndex) {
                    var GiftData = _.filter(_PageData.Commodity.Gift.Data, {RoomTemplate: ["IMax2"]});
                    var AnchorTags = $.CommonMainRoom.RoomAnchorInfo.Tags;
                    GiftData = GiftDataFilter(AnchorTags, GiftData);

                    var index = 0;
                    var GiftList = "";
                    if (GiftData.length <= 0) {
                        GiftList += '<li class="noResult">';
                        GiftList += ' 暂无！';
                        GiftList += '</li>';
                    }
                    for (var i = 0; i < GiftData.length; i++) {
                        var Value = GiftData[i];
                        if (Value.Status != 0) continue;
                        var SuperTag = '';
                        var BgColor = (Value.BgColor) ? 'style="background-color:#' + String(Value.BgColor.toString(16)).replace('0x', '') + ';"' : '';
                        if (_.includes(Value.Tag, "Lucky")) {
                            //幸运
                            SuperTag += '<div class="supertag supertag-luck"></div>';
                        }
                        if (_.includes(Value.Tag, "WeekStar")) {
                            //周星
                            SuperTag += '<div class="supertag supertag-week"></div>';
                        }
                        if (_.includes(Value.Tag, "Activity")) {
                            //活动
                            SuperTag += '<div class="supertag supertag-huo"></div>';
                        }
                        var TagData = 'data-id="' + Value.id +
                            '" data-name="' + Value.Name +
                            '" data-Price="' + Value.Price +
                            '" data-Intro="' + Value.Intro +
                            '" data-Streamer-Num="' + (Value.Streamer ? Value.Streamer.Num : 0) +
                            '" data-Streamer-Level="' + (Value.Streamer ? Value.Streamer.Level : 0) + '"';
                        // if (Value.id == _ThisPage.Page.Gift.Data.GiftId) {
                        if (index == _ThisPage.Page.Gift.Data.GiftDefaultShowIndex) {
                            _ThisPage.Page.Gift.Data.GiftId = parseInt(Value.id);
                            _ThisPage.Page.Gift.Data.GiftNum = parseInt($('#J_GiftInputNum').val());
                            _ThisPage.Page.Gift.GiftCountShow({GiftId: Value.id, GiftName: Value.Name});
                            GiftList += '<li class="active" ' + TagData + '>';
                        } else {
                            GiftList += '<li ' + TagData + '>';
                        }
                        GiftList += '<a href="javascript:void(0);">';
                        GiftList += '<img src="' + _VirtualPath.Static + 'main/image/room/gift/' + Value.id + '.png" ' + BgColor + '>';
                        GiftList += SuperTag;
                        GiftList += '</a>';
                        GiftList += '</li>';
                        index++;
                    }
                    $("#J_GiftPanel>#J_GiftListItem").empty().append(GiftList);

                    //艺人Tag = 礼物Tag 匹配相应礼物
                    function GiftDataFilter(AnchorTags, GiftDataArr) {
                        var a = [];
                        if (AnchorTags != null) {
                            for (var i = 0; i < GiftDataArr.length; i++) {
                                var GiftData = GiftDataArr[i];
                                var GiftAnchorTags = GiftData.AnchorTags;
                                if (GiftAnchorTags == null) {
                                    AddData(a, GiftData);
                                } else if (GiftAnchorTags.length > 0) {
                                    if (checkData(AnchorTags, GiftAnchorTags)) {
                                        AddData(a, GiftData);
                                    }
                                }
                            }
                        } else {
                            for (var i = 0; i < GiftDataArr.length; i++) {
                                var GiftData = GiftDataArr[i];
                                var GiftAnchorTags = GiftData.AnchorTags;
                                if (GiftAnchorTags == null || GiftAnchorTags.length <= 0) {
                                    AddData(a, GiftData);
                                }
                            }
                        }
                        function AddData(a, GiftData) {//兼容PurchaseMode = undefined
                            if (GiftData.PurchaseMode == undefined || GiftData.PurchaseMode <= 1){
                                if(!checkWd(GiftData)){
                                    a.push(GiftData);
                                }
                            }
                        }
                        return a;
                    }
                    //检查是否符合，类似【最美COSER】的标签
                    function checkData(Arr1, Arr2) {
                        for (var j = 0; j < Arr2.length; j++) {
                            if (_.includes(Arr1, Arr2[j])) {
                                return true;
                            }
                        }
                        return false;
                    }
                    //房间ID 幸运礼物 不要显示
                    function checkWd(GiftData){
                        var WD_Arr = [];//[RoomID]
                        var b = (_.includes(WD_Arr, parseInt(_PageData.RoomID)) && _.includes(GiftData.Tag, "Lucky"));
                        return b;
                    }

                },
                //礼物赠送 返回 结果 temp
                RoomGiftGiveResult: function (data) {
                    var _This = _ThisPage.Page.Gift;
                    //为数据兼容做的
                    var giftData = {
                        CreateDate: data.CreateDate,
                        Count: data.GiftCount,
                        GiftStreamer: data.GiftStreamer,
                        Gift_ID: data.GiftInfo.id,
                        GiftName: data.GiftInfo.Name,
                        // Gift_Pond_Amt:data.GiftPond.Amt,
                        // Gift_Pond_TriggerAmt:data.GiftPond.BurstAmt,
                        Num: data.GiftNum,
                        UserInfo: data.RoomUserInfo,
                        UserInfo_Gift: (data.RoomUserInfo_Gift) ? data.RoomUserInfo_Gift : data.RoomAnchorInfo,
                        RoomAnchor: (data.RoomUserInfo_Gift) ? false : true,
                        RoomAnchorInfo: $.CommonMainRoom.RoomAnchorInfo
                    };
                    giftData.UserInfo_Gift.RoomAnchor = true;

                    //显示礼物历史记录
                    _This.GiftHistoryList(giftData);

                    //显示 礼物记录赠送 聊天区
                    _ThisPage.Page.Chat.GiftTip(giftData);

                    //显示 大礼物效果
                    _ThisPage.Page.GiftBig.Update2(data);

                    //显示流光效果 Flash
                    var StreamerData = {
                        UserId: data.RoomUserInfo.User_ID,
                        NickName: data.RoomUserInfo.NickName,
                        GiftId: data.GiftInfo.id,
                        GiftName: data.GiftInfo.Name,
                        GiftCount: data.GiftCount,
                        GiftNum: data.GiftNum,
                        Streamer: data.GiftStreamer,
                        Path: _VirtualPath
                    };
                    onJsToAs({type: "StreamerAddData", data: StreamerData});

                    //显示礼物成组效果
                    onJsToAs({type: "GiftGroupEffect", data: {giftId: data.GiftInfo.id, giftNum: data.GiftNum}});

                    //幸运礼物暴奖文字
                    if (data.LuckyCoin > 0) {
                        var LuckyStr = "";
                        var a = data.LuckyMultipleList;
                        for (var i = 0; i < a.length; i++) {
                            var LuckyData = a[i];
                            LuckyStr += LuckyData.Multiple + '倍' + LuckyData.Count + '次，';
                        }
                        _ThisPage.Page.Chat.SysText('恭喜 <span title="'+data.RoomUserInfo.NickName+'" data-uid="'+data.RoomUserInfo.User_ID+'" class="chat-board-nickname">'+data.RoomUserInfo.NickName+'</span> 送出 ' + data.GiftNum + '个“' + data.GiftInfo.Name + '” 喜中 ' + LuckyStr + '共获得' + data.LuckyCoin + '金币！');
                    }
                },
                //艺人显示 礼物历史记录
                GiftHistoryList: function (data) {
                    if (!$.CommonMainRoom.RoomUserInfo.RoomAnchor) return;
                    // 历史记录
                    var html = '<li><span class="time">{time}</span><a href="javascript:;" class="nickname">{user1}</a>送&nbsp;&nbsp;<span class="gift">{giftname}＊{num}个' + (data.Gift_ID == 0 ? '' : '{group}组') + '</span></li>';
                    html = html.replaceAll('{time}', moment(data.CreateDate).format('HH:mm'));
                    html = html.replaceAll('{user1}', data.UserInfo.NickName);
                    html = html.replaceAll('{user2}', data.RoomAnchorInfo.NickName);
                    html = html.replaceAll('{giftname}', data.GiftName);
                    html = html.replaceAll('{num}', data.Num);
                    html = html.replaceAll('{group}', data.Count);
                    $('#J_GiftHistoryList').prepend(html);
                    if ($('#J_GiftHistoryList li').length > 100) {
                        $('#J_GiftHistoryList li')[100].remove();
                    }
                },
                //选择某礼物 后 数量区显示
                GiftCountShow: function (data) {
                    _ThisPage.Page.Gift.Data.GiftId = data.GiftId;
                    $('#J_GiftSelectImg').attr('src', _VirtualPath.Static + 'main/image/room/gift/' + data.GiftId + '.png');
                    $('#J_GiftSelectImg').attr('alt', data.GiftName);
                },
                //显示赠送按钮 倒计时 动画
                ShowGiftBtnAnimation: function () {
                    // $("#J_GiftSendBtnProgress").show();
                    // $("#J_GiftSendBtnProgressNum").show();
                    // $("#J_GiftSendBtnProgressText").hide();
                    // if($("#J_GiftSendBtnProgress").hasClass("GiftSendBtnProgress")){
                    //     $("#J_GiftSendBtnProgress").removeClass("GiftSendBtnProgress");
                    // }
                    //
                    // _ThisPage.Page.Gift.Data.IntervalNum = 4;
                    // $("#J_GiftSendBtnProgressNum").text(_ThisPage.Page.Gift.Data.IntervalNum);
                    //
                    // clearTimeout(_ThisPage.Page.Gift.Data.GiftSendBtnTimeout);
                    // _ThisPage.Page.Gift.Data.GiftSendBtnTimeout = setTimeout(function(){$("#J_GiftSendBtnProgress").addClass("GiftSendBtnProgress")},1);
                    //
                    // clearInterval(_ThisPage.Page.Gift.Data.GiftSendBtnInterval);
                    // _ThisPage.Page.Gift.Data.GiftSendBtnInterval = setInterval(function () {
                    //     _ThisPage.Page.Gift.Data.IntervalNum--;
                    //     $("#J_GiftSendBtnProgressNum").text(_ThisPage.Page.Gift.Data.IntervalNum);
                    //     if(_ThisPage.Page.Gift.Data.IntervalNum<=0){
                    //         clearInterval(_ThisPage.Page.Gift.Data.GiftSendBtnInterval);
                    //         $("#J_GiftSendBtnProgress").hide();
                    //         $("#J_GiftSendBtnProgressNum").hide();
                    //         $("#J_GiftSendBtnProgressText").show();
                    //         // _ThisPage._TempData.GiftData.sending = false;
                    //     }
                    // },1000);
                },
                //更新包裹礼物
                UpdateUserPackage: function (dataList) {
                    if (_ThisPage.Page.Gift.Data.CurrTag == "Package") {
                        _ThisPage.Page.Gift.ShowPackage();
                    }
                },
                ShowPackage: function () {
                    var GiftData = $.CommonMainRoom.UserPackage;
                    var GiftList = "";
                    if (GiftData.length <= 0) {
                        GiftList += '<li class="noResult">';
                        GiftList += ' 暂无！';
                        GiftList += '</li>';
                    }
                    for (var i = 0; i < GiftData.length; i++) {
                        var Value = GiftData[i];
                        if (Value.Item_Type == "Gift") {
                            var SuperTag = '';
                            if (_.includes(Value.Tag, "Lucky")) {
                                //幸运
                                SuperTag += 'supertag supertag-luck';
                            }
                            if (_.includes(Value.Tag, "WeekStar")) {
                                //周星
                                SuperTag += ' supertag-week';
                            }
                            if (_.includes(Value.Tag, "Activity")) {
                                //活动
                                SuperTag += ' supertag-huo';
                            }
                            var TagData = 'data-id="' + Value.Item_Info.id +
                                '" data-name="' + Value.Item_Info.Name +
                                '" data-Price="' + Value.Item_Info.Price + '' +
                                '" data-Intro="' + Value.Item_Info.Intro + '' +
                                '" data-Streamer-Num="' + Value.Item_Info.Streamer.Num +
                                '" data-Streamer-Level="' + Value.Item_Info.Streamer.Level +
                                '" data-Num="' + Value.Num +
                                '"';
                            if (i == _ThisPage.Page.Gift.Data.PackageDefaultShowIndex) {
                                _ThisPage.Page.Gift.Data.GiftId = parseInt(Value.Item_Info.id);
                                _ThisPage.Page.Gift.Data.GiftNum = parseInt($('#J_GiftInputNum').val());
                                _ThisPage.Page.Gift.GiftCountShow({GiftId: Value.Item_Info.id, GiftName: Value.Item_Info.Name});
                                GiftList += '<li class="active" ' + TagData + '>';
                            } else {
                                GiftList += '<li ' + TagData + '>';
                            }
                            GiftList += '<a href="javascript:void(0);">';
                            GiftList += '<img src="' + _VirtualPath.Static + 'main/image/room/gift/' + Value.Item_Info.id + '.png">';
                            GiftList += '<span class="bag-total">' + Value.Num + '</span>';
                            GiftList += '<div class="' + SuperTag + '">';
                            GiftList += '</div>';
                            GiftList += '</a>';
                            GiftList += '</li>';
                        }
                    }
                    $("#J_GiftPackagePanel>#J_GiftListItem").empty().append(GiftList);
                }
            },
            /**
             * 头条
             */
            GiftHeadline: {
                Data: {
                    TempInterval1: 0,
                    Headline: null
                },
                Init: function (data) {
                    $('#J_HeadlineGuradTimeCount').text(_PageData.Commodity.Gift.Headline.GuardTime);
                    $('#J_HeadlineTriggerAmtCount').text(_PageData.Commodity.Gift.Headline.TriggerAmt);

                    clearInterval(_ThisPage.Page.GiftHeadline.Data.TempInterval1);
                    _ThisPage.Page.GiftHeadline.Data.TempInterval1 = setInterval(function () {
                        if (_ThisPage.Page.GiftHeadline.Data.Headline == null) return;
                        if (_ThisPage.Page.GiftHeadline.Data.Headline.GuardTime_Left < 0) return;

                        _ThisPage.Page.GiftHeadline.UpdateGuardTimeBar({
                            GuardTime_Left: _ThisPage.Page.GiftHeadline.Data.Headline.GuardTime_Left--,
                            GuardTime: _ThisPage.Page.GiftHeadline.Data.Headline.GuardTime
                        });
                    }, 1000);
                },
                UpdateGiftHeadline: function (data) {
                    Log.Out("更新头条数据：：：", data);

                    $('#J_HeadlineContent, #J_CurrentRemainingTime').show();
                    $("#J_HeadlineNone").hide();

                    $('#J_HeadlineContent').css({position: 'absolute', top: '60px', left: "48px", width: '292px', height: "40px"});
                    $("#J_HeadlineContent").animate({top: '5px', left: "48px"}, 1000, "swing");
                    _ThisPage.Page.GiftHeadline.Data.Headline = data;
                    $('#J_HeadlineUserNickname').text(data.User_NickName);
                    $('#J_HeadlineGiftName').text(data.GiftInfo.Name);
                    $('#J_HeadlineGiftCount').text(data.GiftNum);
                    $('#J_HeadlineAnchorNickname').text(data.Anchor_NickName);
                    $('#J_HeadlineGiftImg').attr('src', _VirtualPath.Static + 'main/image/room/gift/' + data.GiftInfo.id + '.png');
                    $('#J_HeadlineUserNickname, #J_HeadlineAnchorNickname').attr('href', "/room/" + data.Anchor_ID);
                    _ThisPage.Page.GiftHeadline.UpdateGuardTimeBar(data);

                    $('#J_HeadlineBroadcastContent').css({cursor:'pointer'});
                    $('#J_HeadlineBroadcastContent').off('click');
                    $('#J_HeadlineBroadcastContent').on('click', function(){
                        window.open('/room/'+data.Anchor_ID);
                    });
                },
                UpdateGuardTimeBar: function (data) {
                    var percent = data.GuardTime_Left / data.GuardTime * 100;
                    $('#J_HeadlineGuardTime').width(percent + '%');
                    var time = getNum(Math.floor(data.GuardTime_Left / 60)) + ':' + getNum(Math.floor(data.GuardTime_Left % 60));
                    $('#J_HeadlineSurplusTime').text(time);

                    function getNum(n) {
                        if (n < 10) {
                            return '0' + n;
                        }
                        return n;
                    }

                }
            },
            /**
             * 大礼物效果
             */
            GiftBig:{
                Init:function (data) {
                    if(data.GiftFloat == null || data.GiftFloat == undefined) return;
                    if(data.GiftFloat.length <= 0) return;
                    for(var i=0; i<data.GiftFloat.length; i++){
                        var o = data.GiftFloat[i];
                        _ThisPage.Page.GiftBig.Update(o);
                    }
                },
                Update:function (data) {
                    var myData = {
                        UserInfo:{User_ID:data.User_ID, NickName:data.User_NickName},
                        GiftInfo:data.GiftInfo,
                        GiftNum:data.GiftNum,
                        GiftFloat:(data.Duration) ? data.Duration : 30, //默认30秒
                        Path:_VirtualPath
                    };
                    // myData.Path.Utils_CDN = "http://127.0.0.1:2900/";
                    if (_ThisPage.Flash.Data.isInit) {
                        //Flash跑道后续效果
                        onJsToAs({type:"RunwayFollowUpEffect", data:myData});
                    } else {
                        _ThisPage.Flash.Data.Event.push({type: "RunwayFollowUpEffect", data:myData});
                    }
                },
                Update2:function(data){
                    if(!data.GiftInfo.EffectDuration){
                        return ;
                    }
                    var myData = {
                        UserInfo:{User_ID:data.User_ID, NickName:data.User_NickName},
                        GiftInfo:data.GiftInfo,
                        GiftNum:data.GiftNum,
                        GiftFloat:(data.Duration) ? data.Duration : 30, //默认30秒
                        Path:_VirtualPath
                    };
                    if (_ThisPage.Flash.Data.isInit) {
                        onJsToAs({type:"RunwayFollowUpEffect", data:myData});
                    } else {
                        _ThisPage.Flash.Data.Event.push({type: "RunwayFollowUpEffect", data:myData});
                    }
                }
            },
            /**
             * 守护功能
             */
            Guardian: {
                Data: {
                    id: "",
                    Arr: [],
                    IsShowing: false //是否 效果显示中
                },
                Init: function (data) {
                    $('#J_GuardPrice').text(_PageData.Commodity.Guardian.Data[0].Price);

                    //开通守护 按钮 事件
                    $("#J_AnchorGuardBuy,#J_UserBuyGuardBtn").on('click', function (event) {
                        event.preventDefault();
                        if (!$.CommonMain.LoginCheck()) return;
                        var elem = $('.modal-guard-box');
                        dialog({
                            title: '开通守护',
                            content: elem,
                            id: 'ID_Modal_10001',
                            padding: '0',
                            cancel: function () {
                            },
                            cancelValue: '取消',
                            ok: function () {
                                if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                                    //_ThisPage.Page.CommonUitls.Tip("");
                                    $.CommonMain.Modal_Tip("您不能给自己开通守护！", {Timeout: 2000});
                                    return;
                                }
                                $.CommonMainRoom.SocketEmit.Guardian(_ThisPage.Page.Guardian.Data.id);
                            },
                            okValue: '购买',
                        }).show();
                        _ThisPage.Page.Guardian.Data.id = _PageData.Commodity.Guardian.Data[0].id;

                        $('.g-r').on('click', 'a', function () {
                            var index = $(this).index();
                            $('#J_GuardPrice').text(_PageData.Commodity.Guardian.Data[index].Price);
                            $(this).addClass('active').siblings().removeClass('active');
                            // $('#J_GuardPriceDel').text(_PageData.Commodity.Guardian.Data[index].Price);//原价
                            // $(this).addClass('active s-half').siblings().removeClass('active s-half');//含打折标签
                            _ThisPage.Page.Guardian.Data.id = _PageData.Commodity.Guardian.Data[index].id;
                        });
                    });

                    //加载数据
                    _ThisPage.Page.Guardian.LoadGuardianList();

                },
                //加载守护列表
                LoadGuardianList: function () {
                    $.getJSON(_VirtualPath.Main + "ajax/user.user-anchor-guardian.list-guardian", {
                        User_ID: $.CommonMainRoom.RoomInfo.RoomID
                    }, function (json) {
                        if (json.flag !== 0) {
                            _ThisPage.Page.CommonUitls.Tip("Error " + json.msg + " " + json.flag);
                            return;
                        }
                        // Log.Out("守护列表数据", json.data);

                        var arr = json.data;
                        arr.reverse();
                        $("#J_GuardNum").text(arr.length);
                        arr.forEach(function (value) {
                            _ThisPage.Page.Guardian.AddGuardListItem(value);
                        });
                    });
                },
                //添加守护ITEM到 列表
                AddGuardListItem: function (data) {
                    var expire = moment(data.Guardian_Expire);
                    var Guardian_ExpireDay = expire.diff(moment(), 'days');
                    if (data.User_ID == $("#J_GuardList li[data-uid=" + data.User_ID + "]").attr("data-uid")) {
                        $("#J_GuardList li[data-uid=" + data.User_ID + "]").find('.guard-time').text(Guardian_ExpireDay + "天");
                        if (data.Guardian_Mode == "YEAR") {
                            $('<span class="ico-guard-year"></span>').insertAfter($("#J_GuardList li[data-uid=" + data.User_ID + "]").find('.guard-time'));
                        }
                        return;
                    }

                    var g = '<li data-uid="' + data.User_ID + '">';
                    g += '<a href="javascript:;">';
                    g += '<img src="' + _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID, "54.54") + '" alt=' + data.NickName + ' class="cover">';
                    g += '<span class="guard-time" title="' + data.NickName + '">' + Guardian_ExpireDay + '天</span>';
                    if (data.Guardian_Mode == "YEAR") g += '<span class="ico-guard-year"></span>';
                    g += '</a>';
                    g += '</li>';

                    $("#J_GuardList").prepend(g);
                    // $("#J_GuardList").append(g);
                },
                //守护购买结果
                BuyResult: function (data) {
                    var userInfo = {
                        Create_Date: data.CreateDate,
                        Create_IP: "",
                        EXP: data.RoomUserInfo.EXP,
                        Guardian_Expire: data.RoomUserInfo.RoomGuardian_Expire,
                        Guardian_ID: data.GuardianInfo.id,
                        Guardian_Mode: data.GuardianInfo.Mode,
                        Guardian_Name: data.GuardianInfo.Name,
                        IsAnchor: data.RoomUserInfo.IsAnchor,
                        IsFamily: data.RoomUserInfo.IsFamily,
                        NickName: data.RoomUserInfo.NickName,
                        Level: data.RoomUserInfo.Level,
                        RealName: "",
                        User_ID: data.RoomUserInfo.User_ID,
                        User_ID_Guardian: data.RoomUserInfo.RoomID,
                        VIP: data.RoomUserInfo.VIP,
                        VIP_Expire: data.RoomUserInfo.VIP_Expire
                    };
                    var _This = this;
                    if (_ThisPage.Page.Gift.Data.isEffectOn) {
                        _This.Data.Arr.push(userInfo);
                    }
                    _This.ShowGuardEffect();
                    _This.AddGuardListItem(userInfo);
                    $("#J_GuardPop").hide();
                },
                //显示 购买守护效果
                ShowGuardEffect: function () {
                    var _This = _ThisPage.Page.Guardian;
                    if (_This.Data.Arr.length <= 0) return;
                    if (_This.Data.IsShowing) return;
                    _This.Data.IsShowing = true;

                    var data = _This.Data.Arr[0];
                    $('#J_GuardEffectPanel_UserHead').attr('src', _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID));
                    $('#J_GuardEffectPanel_UserInfo').html('<span class="tag-user-level ico-level-' + data.Level + '"></span><span class="nickname">' + data.NickName + '</span>');
                    $('.main-broadcast-guard').show();
                    _This.Data.Arr.splice(0, 1);

                    setTimeout(function () {
                        if (_This.Data.Arr.length > 0) {
                            $('.main-broadcast-guard').hide();
                            _This.Data.IsShowing = false;
                            setTimeout(_This.ShowGuardEffect, 300);
                        } else {
                            setTimeout(function () {
                                $('.main-broadcast-guard').hide();
                                _This.Data.IsShowing = false;
                                if (_This.Data.Arr.length > 0) setTimeout(_This.ShowGuardEffect, 300);
                            }, 3000);
                        }
                    }, 3000);
                },
                //守护更新通知
                UpdateNotify: function (data) {
                    //更新人员列表守护图标
                    // if (data.RoomGuardian && data.RoomGuardian_Mode == "MONTH") {
                    //     if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-year.png']").length > 0) {
                    //         $("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-year.png']").remove();
                    //     }
                    //     if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-month.png']").length <= 0) {
                    //         $("#J_UserList li[data-uid=" + data.User_ID + "]").append('<span><img src="' + _VirtualPath.Static + '/main/image/room/icon/Ico-guard-month.png" alt="月守护"></span>');
                    //     }
                    // }
                    //
                    // if (data.RoomGuardian && data.RoomGuardian_Mode == "YEAR") {
                    //     if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-month.png']").length > 0) {
                    //         $("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-month.png']").remove();
                    //     }
                    //     if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-year.png']").length <= 0) {
                    //         $("#J_UserList li[data-uid=" + data.User_ID + "]").append('<span><img src="' + _VirtualPath.Static + '/main/image/room/icon/Ico-guard-year.png" alt="年守护"></span>');
                    //     }
                    // }

                    //更新房间通知
                    var _Level = data.RoomAnchor ? "anchor/" + data.Level : "user/" + data.Level;
                    var msg = '';
                    msg += '<li class="main-chat-item main-chat-item-guarded">';
                    msg += '<div class="main-chat-userinfo"><div class="main-chat-tags"><span class="main-chat-tag-user-official"></span></div><span class="chat-board-nickname">系统消息</span></div>';
                    msg += '<div class="main-chat-message">'
                    // msg += '<span class="chat-board-text-system">系统消息:</span>';
                    msg += '<span class="chat-board-text-gx">恭喜</span>';
                    // msg += '<span class="main-chat-tag-user-level ico-level-' + data.Level + '" title="用户等级-' + data.Level + '"></span>';
                    //
                    // if (data.VIP > 0) {
                    //     msg += '<span class="main-chat-tag-user-vip" title="VIP"></span>';
                    // }
                    // if (data.RoomAdmin) {
                    //     msg += '<span class="main-chat-tag-user-admin" title="Admin"></span>';
                    // }
                    // if (data.RoomGuardian && data.RoomGuardian_Mode == "MONTH") {
                    //     msg += '<span class="main-chat-tag-user-guard-month" title="月守护"></span>';
                    // }
                    // if (data.RoomGuardian && data.RoomGuardian_Mode == "YEAR") {
                    //     msg += '<span class="main-chat-tag-user-guard-year" title="年守护"></span>';
                    // }
                    msg += ' <span class="chat-board-nickname" data-uid=' + data.User_ID + '>' + data.NickName + '</span>';
                    msg += '  成为该房间的守护神，吾身为剑，守你万事平安，吾魂为盾，护你岁月静好～ ';
                    msg += '</div>';
                    msg += '</li>';
                    $("#J_Chatlistinfo").append(msg);

                    if (!data.Guest) {
                        //为兼容聊天区 数据格式
                        var UserInfo = {};
                        UserInfo.EXP = data.EXP;
                        UserInfo.EXP_Next = data.EXP_Next;
                        UserInfo.Family_ID = data.Family_ID;
                        UserInfo.GiftLast = [];
                        UserInfo.Guest = data.Guest;
                        UserInfo.IsAnchor = data.IsAnchor;
                        UserInfo.IsFamily = data.IsFamily;
                        UserInfo.Level = data.Level;
                        // UserInfo.EXP_Difference
                        UserInfo.Level_Next = data.Level_Next;
                        UserInfo.NickName = data.NickName;
                        UserInfo.Pomelo = data.Pomelo;
                        UserInfo.RoomAdmin = data.RoomAdmin;
                        UserInfo.RoomAnchor = data.RoomAnchor;
                        UserInfo.RoomBlack = data.RoomBlack;
                        UserInfo.RoomBlack_Shutup_Expire = data.RoomBlack_Shutup_Expire;
                        UserInfo.RoomGuardian = data.RoomGuardian;
                        UserInfo.RoomGuardianExpire = data.RoomGuardian_Expire;
                        UserInfo.RoomGuardianExpireDay = data.RoomGuardian_ExpireDay
                        UserInfo.RoomGuardianMode = data.RoomGuardian_Mode;
                        UserInfo.User_ID = data.User_ID;
                        UserInfo.VIP = data.VIP;
                        UserInfo.VIP_Expire = data.VIP_Expire;
                        // $("#J_Chatlistinfo span[data-uid=" + data.Data.User_ID + "]").data('userdata', data.Data);
                        $("#J_Chatlistinfo span[data-uid=" + data.User_ID + "]").data('userdata', UserInfo);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();

                }
            },
            /**
             * 人员列表
             */
            UserList: {
                Data: {
                    CurrListUserCount:0,//当前列表实际人数 包括机器人
                    UserCount: 0, //人员列表人数，官方人员需要数量不要显示在里面。
                    ListArr: [], //人员列表数据
                    AdminListArr: [], //场控列表
                },
                Init: function () {
                    //在线人员，向下滚动时，显示部分机器人。
                    $(".main-online-user-wrap").perfectScrollbar();
                    $(".main-online-user-wrap").on('ps-scroll-down',function (e) {
                        Log.Out('滚动。。。', [$(".main-online-user-wrap > .ps-scrollbar-y-rail").position().top, $(".main-online-user-wrap > .ps-scrollbar-y-rail").css('top')].toString());
                        if($(".main-online-user-wrap > .ps-scrollbar-y-rail").position().top < 0 && _ThisPage.Page.UserList.Data.CurrListUserCount < _ThisPage.Page.UserList.Data.UserCount){
                            _ThisPage.Page.RobotManage.AddRobot();
                        }
                    });
                },
                //加载用户列表
                LoadList: function () {
                    $.CommonMainRoom.SocketEmit.UserList();
                },
                //加载完成的用户列表
                Result: function (arr) {
                    $("#J_RoomUserList").empty();
                    $("#J_RoomAdminList").empty();
                    _ThisPage.Page.UserList.Data.UserCount = 0;
                    var AdminCount = 0;
                    this.Data.ListArr = arr;
                    Log.Out('用户列表', arr);
                    this.Data.ListArr.forEach(function (value) {
                        if (value.RoomAdmin) {
                            _ThisPage.Page.UserList.Admin.AddUserItem(value);
                            AdminCount++;
                        } else {
                            _ThisPage.Page.UserList.AddUserItem(value);
                            _ThisPage.Page.UserList.Data.UserCount++;
                            _ThisPage.Page.UserList.Data.CurrListUserCount++;
                        }
                    });

                    //加入 机器人 相应数量
                    _ThisPage.Page.UserList.Data.UserCount += _ThisPage.Page.RobotManage.Init();

                    $("#J_RoomUserCount,#J_RoomUserListCount").text(_ThisPage.Page.UserList.Data.UserCount);
                    $('#J_AdminUserCount').text(AdminCount);
                    // _ThisPage.Page.UserList.Data.ListArr = null;
                },
                //添加新用户到用户列表
                AddUserItem: function (data, isRobot) {
                    var _Level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                    var _Style = data.RoomAnchor ? 'tag-anchor-level  ico-anchor-level-' + _Level : 'tag-user-level  ico-level-' + _Level;
                    var userItem = '';
                    userItem += '<li data-uid="' + data.User_ID + '">';
                    userItem += '<span class="' + _Style + '"></span>';
                    if (data.IsMobile) userItem += '<span class="main-chat-tag-plat-mobile" title="手机"></span>';
                    if (data.VIP) userItem += '<span class="main-chat-tag-user-vip" title="VIP"></span>';
                    if (data.RoomGuardian && (data.RoomGuardian_Mode == "MONTH" || data.RoomGuardianMode == "MONTH")) userItem += '<span class="main-chat-tag-user-guard-month" title="月守护"></span>';
                    if (data.RoomGuardian && (data.RoomGuardian_Mode == "YEAR" || data.RoomGuardianMode == "YEAR")) userItem += '<span class="main-chat-tag-user-guard-year" title="年守护"></span>';
                    userItem += '<a href="javascript:;" class="nickname">' + data.NickName + '</a>';
                    userItem += '</li>';
                    //服务端排序
                    if (isRobot) {
                        $("#J_RobotList").append(userItem);
                    } else {
                        $("#J_RoomUserList").append(userItem);
                    }
                    $("#J_RoomUserList li[data-uid=" + data.User_ID + "]").data("key", data);
                    $("#J_RoomUserList li[data-uid=" + data.User_ID + "]").off('click');
                    $("#J_RoomUserList li[data-uid=" + data.User_ID + "]").on('click', function (e) {
                        if (!$.CommonMain.LoginCheck()) return;
                        var _left = $(this).offset().left - 218 / 2 + 100;
                        var _top = $(this).offset().top + $(this).height() + 8;
                        $("#J_UserCardPop").data('userinfo', data);
                        $("#J_UserCardPop").css({
                            left: _left,
                            top: _top,
                            zIndex: 1000
                        }).fadeIn();
                        $("#J_UserCardPop .MCard-Arrow").css({
                            left: "12px"
                        })
                        _ThisPage.Page.CommonUitls.CreateUserInfoMiniCard(data);
                    });
                },
                //场控列表
                Admin: {
                    LoadList: function () {
                        $.CommonMainRoom.SocketEmit.AdminList();
                    },
                    Result: function (arr) {
                        Log.Out('场控列表', arr);
                        $("#J_AdminUserCount").text(arr.length);
                        $("#J_RoomAdminList").empty();
                        arr.forEach(function (value) {
                            // value.RoomAdmin = true;//测试用场控
                            // Log.Out("场控列表Item", value);
                            _ThisPage.Page.UserList.Admin.AddUserItem(value);
                        });
                    },
                    //添加新用户到用户列表
                    AddUserItem: function (data, isRobot) {
                        data.RoomAdmin = true;

                        var _Level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                        var _Style = data.RoomAnchor ? 'tag-anchor-level  ico-anchor-level-' + _Level : 'tag-user-level  ico-level-' + _Level;
                        var userItem = '<li data-uid="' + data.User_ID + '">';
                        userItem += '<span class="' + _Style + '"></span>';
                        if (data.VIP) userItem += '<span class="main-chat-tag-user-vip" title="VIP"></span>';
                        if (data.RoomGuardian && (data.RoomGuardian_Mode == "MONTH" || data.RoomGuardianMode == "MONTH")) userItem += '<span class="main-chat-tag-user-guard-month" title="月守护"></span>';
                        if (data.RoomGuardian && (data.RoomGuardian_Mode == "YEAR" || data.RoomGuardianMode == "YEAR")) userItem += '<span class="main-chat-tag-user-guard-year" title="年守护"></span>';
                        userItem += '<a href="javascript:;" class="nickname">' + data.NickName + '</a>';
                        userItem += '</li>';
                        $("#J_RoomAdminList").append(userItem);

                        $("#J_RoomAdminList li[data-uid=" + data.User_ID + "]").data("key", data);
                        $("#J_RoomAdminList li[data-uid=" + data.User_ID + "]").off('click');
                        $("#J_RoomAdminList li[data-uid=" + data.User_ID + "]").on('click', function (e) {
                            if (!$.CommonMain.LoginCheck()) return;
                            var _left = $(this).offset().left + 8;
                            var _top = $(this).offset().top + $(this).height() + 8;
                            $("#J_UserCardPop").data('userinfo', data);
                            $("#J_UserCardPop").css({
                                left: _left,
                                top: _top,
                                zIndex: 1000
                            }).fadeIn();
                            $("#J_UserCardPop .MCard-Arrow").css({
                                left: "12px"
                            })
                            _ThisPage.Page.CommonUitls.CreateUserInfoMiniCard(data);
                        });
                    },
                }
            },
            /**
             * 用户升级提示
             */
            UserLevelUpgrade: {
                Data: {
                    Arr: [], //升级提示列队
                    Interval: 0, //时间间隔
                    IsStart: false //是否已开始显示
                },
                Test: {
                    Init: function () {
                        var data = {
                            RoomUserInfo: {
                                NickName: "用户昵称",
                                Level: 3
                            }
                        };
                        for (var i = 0; i < 2; i++) {
                            _ThisPage.Page.UserLevelUpgrade.AddItem(data);
                        }
                    }
                },
                AddItem: function (data) {
                    _ThisPage.Page.UserLevelUpgrade.Data.Arr.push(data);
                    if (_ThisPage.Page.UserLevelUpgrade.Data.IsStart) return;
                    _ThisPage.Page.UserLevelUpgrade.Data.IsStart = true;
                    _ThisPage.Page.UserLevelUpgrade._Show(_ThisPage.Page.UserLevelUpgrade.Data.Arr[0]);
                    _ThisPage.Page.UserLevelUpgrade.Data.Arr.splice(0, 1);
                    _ThisPage.Page.UserLevelUpgrade.Data.Interval = setInterval(function () {
                        if (_ThisPage.Page.UserLevelUpgrade.Data.Arr.length <= 0) {
                            clearInterval(_ThisPage.Page.UserLevelUpgrade.Data.Interval);
                            _ThisPage.Page.UserLevelUpgrade.Data.IsStart = false;
                            $("#J_UserLevelTips").html('');
                            return;
                        }
                        _ThisPage.Page.UserLevelUpgrade._Show(_ThisPage.Page.UserLevelUpgrade.Data.Arr[0]);
                        _ThisPage.Page.UserLevelUpgrade.Data.Arr.splice(0, 1);
                    }, 5000);
                },
                _Show: function (data) {
                    var html = '<ul class="WebChatListInfo" id="J_UserLevelTipsHtml" style="background: url(' + _VirtualPath.Static + 'main/image/room/bg-sidebg.png) repeat;width:534px;padding:3px;line-height: 20px;height: 20px;"><li class="enter"><span class="username" data-uid="63">' +
                        data.RoomUserInfo.NickName + '</span> 升级到 <em class="userlev"><img src="' +
                        _VirtualPath.Static + 'main/image/common/level/user/' +
                        data.RoomUserInfo.Level + '.png" alt="' +
                        data.RoomUserInfo.Level + '"></em></li></ul>';
                    $("#J_UserLevelTips").html(html);
                }
            },
            /**
             * 跑道
             */
            Runway: {
                Data: {},
                Test: {
                    Init: function () {
                        for (var i = 0; i < 2; i++) {
                            var data = {
                                Type: "Gift",
                                Data: {
                                    RoomUserInfo_Gift: {
                                        RoomID: 4605,
                                        User_ID: 123,
                                        NickName: "昵称接收",
                                    },
                                    RoomUserInfo: {
                                        RoomID: 4605,
                                        User_ID: 123,
                                        NickName: "昵称送出",
                                    },
                                    GiftInfo: {
                                        id: 60,
                                        Name: "黄瓜"
                                    },
                                    RoomAnchorInfo: {
                                        RoomID: 4605
                                    },
                                    GiftNum: 123
                                }
                            };
                            _ThisPage.Page.Runway.AddRunway(data);
                        }
                    }
                },
                Init: function () {
                    // this.Test.Init();
                },
                AddRunway: function (data) {
                    if (data.Type == "Gift") {
                        data.Data.GiftInfo.GiftNum = data.Data.GiftNum;
                        onJsToAs({
                            type: "RunwayAdd", data: {
                                data: {
                                    userInfo: data.Data.RoomUserInfo,
                                    anchorInfo: data.Data.RoomAnchorInfo,
                                    giftInfo: (data.Data.GiftInfo) ? data.Data.GiftInfo : null,
                                    guardianInfo: (data.Data.GuardianInfo) ? data.Data.GuardianInfo : null,
                                    giftNum: (data.Data.GiftInfo) ? data.Data.GiftNum : 0,
                                    type: data.Data.Type
                                },
                                type: "runway",
                                path: _VirtualPath.Static
                            }
                        });
                    }
                }
            },
            /**
             * 星星
             */
            PomeloUtil: {
                Data: {
                    Num: 0,//星星数量
                    TempInterval: 0,//时间间隔5分钟 获取下星星
                    MaxTime: 60 * 5,//5分钟(秒)
                    CurrTime: 0,//当前时间
                    isFull: false,//当前是否累积满星星了
                    GiftName: '星星',//星星名称，改成【八芒星】
                    GiftId: 0 //暂定 星星ID 为 0
                },
                Init: function (data) {
                    // $(".Beannum").off("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span");
                    // $(".Beannum").on("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span",function(e){
                    //     $(this).remove();
                    // });
                    // $("#J_ShowAddSelfExp").off("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span");
                    // $("#J_ShowAddSelfExp").on("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span",function(e){
                    //     $(this).remove();
                    // });
                    //扔星星 按钮
                    $("#J_PomeloThrowBtn").off("click");
                    $("#J_PomeloThrowBtn").on("click", function (e) {
                        if (!$.CommonMain.LoginCheck()) return;
                        if (_StateData.User_ID == _PageData.RoomID) {
                            $.CommonMain.Modal_Tip('艺人不能送给自己' + _ThisPage.Page.PomeloUtil.Data.GiftName + '！', {Timeout: 1500});
                            Log.Out('艺人不能送给自己' + _ThisPage.Page.PomeloUtil.Data.GiftName + '！');
                            return;
                        }
                        if (_ThisPage.Page.PomeloUtil.Data.Num <= 0) return;
                        _ThisPage.Page.PomeloUtil.Data.Num--;
                        $("#J_SelfPomeloNum").text(_ThisPage.Page.PomeloUtil.Data.Num);
                        $.CommonMainRoom.SocketEmit.PomeloPresent(1);
                        _ThisPage.Page.PomeloUtil.Data.isFull = false;
                    });
                    // $("#J_youziBtn").off("mouseover");
                    // $("#J_youziBtn").on("mouseover",function (e) {
                    //     if(!_StateData.IsLogin) return;
                    //     if(_ThisPage.Page.PomeloUtil.Data.isFull) return;
                    //     $("#J_PomeloTime").show();
                    // });
                    // $("#J_youziBtn").off("mouseout");
                    // $("#J_youziBtn").on("mouseout",function (e) {
                    //     if(!_StateData.IsLogin) return;
                    //     $("#J_PomeloTime").hide();
                    // });

                    //自己显示的星星
                    if (_StateData.IsLogin) {
                        _ThisPage.Page.PomeloUtil.Data.Num = data.Pomelo;
                        $("#J_SelfPomeloNum").text(_ThisPage.Page.PomeloUtil.Data.Num);
                        _ThisPage.Page.PomeloUtil.Data.CurrTime = _ThisPage.Page.PomeloUtil.Data.MaxTime;
                        clearInterval(_ThisPage.Page.PomeloUtil.Data.TempInterval);
                        _ThisPage.Page.PomeloUtil.Data.TempInterval = setInterval(function () {
                            _ThisPage.Page.PomeloUtil.Data.CurrTime--;
                            // $("#J_PomeloTimeNum").text(_ThisPage.Page.PomeloUtil.Data.CurrTime);
                            if (_ThisPage.Page.PomeloUtil.Data.CurrTime <= 0) {
                                $.CommonMainRoom.SocketEmit.PomeloGet();//请求领取星星
                                _ThisPage.Page.PomeloUtil.Data.CurrTime = _ThisPage.Page.PomeloUtil.Data.MaxTime;
                            }
                        }, 1000);//5分钟
                    } else {
                        $("#J_SelfPomeloNum").text("10");//游客默认初始化 10 星星
                    }
                },
                //更新自己的星星数量
                UpdateSelfPomeloNum: function (data) {
                    _ThisPage.Page.PomeloUtil.Data.Num = data.Pomelo;
                    $("#J_SelfPomeloNum").text(_ThisPage.Page.PomeloUtil.Data.Num);
                },
                //显示历史记录 谁赠送的星星
                ShowPomeloHistoryList: function (data) {
                    _ThisPage.Page.PomeloUtil.ShowPomeloAnimation(data.Num);
                    var PomeloData = {
                        CreateDate: data.CreateDate,
                        Gift_ID: _ThisPage.Page.PomeloUtil.Data.GiftId,
                        GiftName: _ThisPage.Page.PomeloUtil.Data.GiftName,
                        Count: 0,
                        Num: 1,
                        RoomAnchor: true,
                        UserInfo: data.RoomUserInfo,
                        UserInfo_Gift: {
                            RoomAnchor: true,
                            NickName: data.RoomAnchorInfo.NickName,
                            Level: data.RoomAnchorInfo.Level
                            // NickName:$.CommonMainRoom.RoomAnchorInfo.NickName,
                            // Level:$.CommonMainRoom.RoomAnchorInfo.Level
                        },
                        RoomAnchorInfo: $.CommonMainRoom.RoomAnchorInfo
                    };
                    // 添加礼物到历史记录列表
                    _ThisPage.Page.Gift.GiftHistoryList(PomeloData);
                    //显示 礼物记录赠送 聊天区
                    Log.Out('PomeloData ======>>> ', [PomeloData, _ThisPage.Page.PomeloUtil.Data.GiftName, , _ThisPage.Page.PomeloUtil.Data.GiftId]);
                    _ThisPage.Page.Chat.GiftTip(PomeloData);
                },
                //增加星星动画
                ShowPomeloAnimation: function (Num) {
                    // $(".Beannum").append('<span class="AnchorPomeloNumTips AnchorPomeloNumStyle">+'+Num+'</span>');
                }
            },
            /**
             * 排行榜
             */
            Ranking: {
                Data: {
                    currType: null //当前 显示的 贡献榜 类型
                },
                Init: function () {
                    //初始显示周榜
                    _ThisPage.Page.Ranking.LoadData(1);

                    //鼠标 移进 移出 排行榜
                    $(".main-rank-list-bd").on('mouseenter', function (event) {
                        $(this).stop(!0, !1).animate({
                            "height": "391px"
                        }, 200)
                    });
                    $(".main-rank-list-bd").on('mouseleave', function (event) {
                        $(this).stop(!0, !1).animate({
                            "height": "152px"
                        }, 200)
                    });
                    //点击 切换排行标签
                    $('#J_RankListTab').off('click');
                    $("#J_RankListTab").on('click', 'a', function (event) {
                        var index = $(this).index();
                        $(this).addClass('active').siblings().removeClass('active');
                        if (index == 3) {
                            $('#J_RoomRankListDiv').hide();
                            $('#J_RoomUserListDiv').show();
                            _ThisPage.Page.UserList.LoadList();
                            // _ThisPage.Page.UserList.Admin.LoadList();
                        } else {
                            $('#J_RoomRankListDiv').show();
                            $('#J_RoomUserListDiv').hide();
                            _ThisPage.Page.Ranking.LoadData(index);
                        }

                    });
                },
                LoadData: function (tabBtnIndex) {
                    var random = Math.floor(new Date().getTime() / 30000) * 30000;//30秒
                    var typeArr = ["Live", "Week", ""];
                    _ThisPage.Page.Ranking.Data.currType = typeArr[tabBtnIndex];
                    $.getJSON("/ajax/user.user-contribution.list?r=" + random, {
                        TopN: 20,
                        User_ID: _PageData.RoomID,
                        OrderBy: typeArr[tabBtnIndex]
                        // OrderBy "Live"://本场排行
                        // OrderBy "Day"://天排行
                        // OrderBy "Week"://周排行
                        // OrderBy "Month"://月排行
                        // OrderBy "Year"://年排行
                        // OrderBy ""://总排行
                    }, function (json) {
                        Log.Out("排行榜数据", json);
                        if (json.flag !== 0) {
                            _ThisPage.Page.CommonUitls.Tip("Error " + json.msg + " " + json.flag);
                            return;
                        }
                        _ThisPage.Page.Ranking.ShowRanking(json.data);
                    });
                },
                ShowRanking: function (data) {
                    $("#J_RankingTop3").empty();
                    $("#J_RankingOther").empty();
                    // Log.Out("排行榜数据", data);
                    _.forEach(data, function (value, key) {
                        var Type = (_ThisPage.Page.Ranking.Data.currType != '') ? '_'+_ThisPage.Page.Ranking.Data.currType : '';
                        var Coin = value["Coin" + Type];
                        if (key < 3) {
                            var item_1 = '<div class="rank-top-row rank-top-row-' + (key + 1) + '">' +
                                '<div class="rank-user-avatar rank-user-avatar-' + (key + 1) + '">' +
                                '<img src="' + _ThisPage.Page.CommonUitls.GetUserHand(value.User_ID) + '">' +
                                '<div class="rank-user-avatar-cover"></div>' +
                                '</div>' +
                                '<div data-name="' + value["NickName"] + '" class="rank-user-name">' + value["NickName"] + '</div>' +
                                '<span class="rank-user-level"><span class="tag-user-level ico-level-' + value["Level"] + '"></span></span>' +
                                '<span class="rank-user-bean"><span class="rank-user-bean-state">' + Coin + '</span></span>' +
                                '</div>';

                            $("#J_RankingTop3").append(item_1);
                        } else {
                            var item_2 = '<div class="rank-row">' +
                                '<span class="rank-icon rank-icon-' + (key + 1) + '">' + (key + 1) + '</span>' +
                                '<span class="rank-user-level">' +
                                '<span class="tag-user-level ico-level-' + value["Level"] + '"></span>' +
                                '</span>' +
                                '<span data-name="' + value["NickName"] + '"  class="rank-user-name">' + value["NickName"] + '</span>' +
                                '<span class="rank-user-bean">' + Coin + '</span>' +
                                '</div>';
                            $("#J_RankingOther").append(item_2);
                        }
                    });
                }
            },
            /**
             * 分享
             */
            Share: {
                Data: {
                    IsEnter: false
                },
                Init: function () {
                    $("title").text($.CommonMainRoom.RoomAnchorInfo.NickName + "的直播间|全民秀网|美女视频|互动娱乐平台");
                    window._bd_share_config.common.bdDesc = '看直播，上#全民秀#！【' +
                        $.CommonMainRoom.RoomAnchorInfo.NickName +
                        '】（房间号：' + $.CommonMainRoom.RoomAnchorInfo.RoomID +
                        '）已入驻全民秀网#视频直播秀#，众多美女都在这里，大家都来看看啊！';
                    window._bd_share_config.common.bdText = window._bd_share_config.common.bdDesc;
                    window._bd_share_config.common.bdPic = _ThisPage.Page.CommonUitls.GetAvatarHand($.CommonMainRoom.RoomAnchorInfo.RoomID, "160.126");
                    window._bd_share_config.common.bdUrl = "http://www.quanminxiu.tv/room/" + $.CommonMainRoom.RoomAnchorInfo.RoomID;
                    with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion=' + ~(-new Date() / 36e5)];
                    _ThisPage.Page.Share.InitBtnEvent();
                },
                InitBtnEvent: function () {
                    $("#J_ShareLinkBtn,#J_SharePanel").off("mouseenter");
                    $("#J_ShareLinkBtn,#J_SharePanel").on("mouseenter", function () {
                        _ThisPage.Page.Share.Data.IsEnter = true;
                        _ThisPage.Page.Share.ShowSharePanel();
                    });
                    $("#J_ShareLinkBtn,#J_SharePanel").off("mouseleave");
                    $("#J_ShareLinkBtn,#J_SharePanel").on("mouseleave", function () {
                        _ThisPage.Page.Share.Data.IsEnter = false;
                        setTimeout(_ThisPage.Page.Share.HideSharePanel, 200);
                    });
                },
                ShowSharePanel: function () {
                    if ($("#J_SharePanel").is(':hidden')) {
                        $("#J_SharePanel").show();
                        $("#J_SharePanel").css({opacity: 0, top: 50});
                        $("#J_SharePanel").animate({opacity: 1, top: 0}, 300, "swing");
                    }
                },
                HideSharePanel: function () {
                    if (!_ThisPage.Page.Share.Data.IsEnter && !$("#J_SharePanel").is(':hidden')) {
                        $("#J_SharePanel").css({opacity: 1});
                        $("#J_SharePanel").animate({opacity: 0, top: -50}, 300, "swing", function () {
                            $("#J_SharePanel").hide();
                        });
                    }
                }
            },
            /**
             * 飞屏，喇叭
             */
            FlyScreen: {
                Data: {
                    FlyScreenMode: "ROOM",//_PageData.Commodity.Horn
                    HornMode: "SERVER"
                },
                //初始化
                Init: function (data) {
                    //飞屏按钮
                    $("#J_FlyScreenBtn").off("click");
                    $("#J_FlyScreenBtn").on("click", function () {
                        if (!$('#J_FlyScreenInputPanel').is(':hidden')) return;
                        $("#J_FlyScreenBtn").css({opacity: 0.5});

                        _ThisPage.Page.FlyScreen.ShowPublishPanel();
                        $("#J_FlyScreenInputText").attr("placeholder", "请输入弹幕文字...");
                        $("#J_FlyScreenPrice").text("2000");

                        var ObjData = _.filter($.CommonMainRoom.UserPackage, {Item_ID: "ROOM"});
                        if (ObjData[0].Num > 0) {
                            $("#J_FreeFlyHornNumDiv").show();
                            $("#J_FreeFlyHornNum").text(ObjData[0].Num);
                        } else {
                            $("#J_FreeFlyHornNumDiv").hide();
                        }
                    });
                    //关闭按钮
                    $("#J_FlyScreenInputPanelCloseBtn").off("click");
                    $("#J_FlyScreenInputPanelCloseBtn").on("click", function () {
                        _ThisPage.Page.FlyScreen.HidePublishPanel();
                        $("#J_InputTextWord").focus();
                    });
                    //文字输入框
                    $("#J_FlyScreenInputText").off("keyup");
                    $("#J_FlyScreenInputText").on("keyup", function () {
                        var count = 30 - $("#J_FlyScreenInputText").val().length;
                        $("#J_FlyScreenTextCount").text(count);
                    });
                    //发布按钮
                    $("#J_FlyScreenPublishBtn").off("click");
                    $("#J_FlyScreenPublishBtn").on("click", function () {
                        if (!$.CommonMain.LoginCheck()) return;

                        var text = $("#J_FlyScreenInputText").val();
                        if (text == null) return;
                        if (text.length <= 0) return;

                        if ($("#J_FlyScreenInputText").attr("placeholder").indexOf("弹幕") != -1) {
                            // _SocketEmit.FlyScreen(text); // 飞屏
                            $.CommonMainRoom.SocketEmit.Horn(_ThisPage.Page.FlyScreen.Data.FlyScreenMode, text);
                        } else {
                            // _SocketEmit.Horn(text); // 喇叭
                            $.CommonMainRoom.SocketEmit.Horn(_ThisPage.Page.FlyScreen.Data.HornMode, text);
                        }
                        $("#J_FlyScreenInputText").val("");
                        $("#J_InputTextWord").focus();
                        _ThisPage.Page.FlyScreen.HidePublishPanel();
                    });

                    _ThisPage.Page.FlyScreen.UpdatePackage();
                },
                //重置 飞屏 喇叭
                ResetHornFly: function () {
                    _ThisPage.Page.Chat.Data.IsHorn = false;
                    _ThisPage.Page.Chat.Data.IsFly = false;
                    $('#J_TalkMsgBtn').addClass('active');
                    $('#J_TalkHornBtn, #J_TalkFlyBtn').removeClass('active');

                    $('.main-chat-sender').removeClass('main-chat-sender-horn main-chat-sender-fly');
                    $("#J_InputTextWord").attr("placeholder", _ThisPage.Page.Chat.Data.LastPlaceholder);
                    _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                    $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                    $('#J_InputTextWord').val('').focus();
                },
                //显示发布面板
                ShowPublishPanel: function () {
                    $("#J_FlyScreenInputPanel").show();
                    $("#J_FlyScreenInputText").val("").focus();
                    $("#J_FlyScreenTextCount").text(30);
                    $("#J_FlyScreenInputPanel").addClass("flipInX animated");
                    $('#J_FlyScreenInputPanel').off('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend');
                    $('#J_FlyScreenInputPanel').on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                        $("#J_FlyScreenInputPanel").removeClass("flipInX animated");
                    });
                },
                //隐藏发布面板
                HidePublishPanel: function () {
                    $("#J_HornBtn,#J_FlyScreenBtn").css({opacity: 1});
                    $("#J_FlyScreenInputPanel").addClass("flipOutX animated");
                    $('#J_FlyScreenInputPanel').off('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend');
                    $('#J_FlyScreenInputPanel').on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                        $("#J_FlyScreenInputPanel").removeClass("flipOutX animated");
                        $("#J_FlyScreenInputPanel").hide();
                    });
                },
                //显示飞屏效果动画
                ShowEffect: function (data) {
                    var userInfo = {
                        type: 'fly',
                        path: _VirtualPath,
                        level: data.RoomUserInfo.Level,
                        userInfo: data.RoomUserInfo,
                        text: data.HornMessage
                    };
                    // onJsToAs({type: "flyscreen_addData", data:userInfo });//以前单独的飞屏效果
                    // if($.CommonMainRoom.RoomInfo.Live){
                    onJsToAs({type: "BarrageAdd", data: userInfo});
                    // }
                },
                //更新包裹飞屏数量
                UpdatePackage: function () {
                    if ($.CommonMainRoom.UserPackage && $.CommonMainRoom.UserPackage.length > 0) {
                        var ObjData = _.filter($.CommonMainRoom.UserPackage, {Item_ID: "ROOM"});
                        if (ObjData.length > 0 && ObjData[0].Num != undefined && ObjData[0].Num > 0) {
                            $("#J_TalkFlyNum").show();
                            $("#J_TalkFlyNum").text(ObjData[0].Num);
                        } else {
                            $("#J_TalkFlyNum").hide();
                        }
                    }
                }
            },
            /**
             * 喇叭
             */
            Horn: {
                Data: {
                    TempInterval: 0,
                    TempTimeOut: 0,
                    TempIndex: 0,
                    Arr: [],
                    ItemArr: [],
                    IsRuning: false,
                    DurationTime: 15 //喇叭持续时间15秒
                },
                Test: {
                    Init: function () {
                        for (var i = 0; i < 5; i++) {
                            var data = {
                                RoomUserInfo: {
                                    Level: 12,
                                    NickName: "用户名" + i
                                },
                                RoomAnchorInfo: {
                                    RoomID: 123,
                                    NickName: "艺人名" + i
                                },
                                HornMessage: i + "_一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十"
                            };
                            _ThisPage.Page.Horn.ShowEffect(data);
                        }
                    }
                },
                Init: function (data) {
                    //测试
                    // _ThisPage.Page.Horn.Test.Init();

                    _ThisPage.Page.Horn.UpdatePackage();
                },
                ShowEffect: function (data) {
                    _ThisPage.Page.Horn.Data.Arr.push(data);
                    this._ShowEffect();
                },
                _ShowEffect: function () {
                    if (_ThisPage.Page.Horn.Data.Arr.length <= 0) return;
                    if (_ThisPage.Page.Horn.Data.IsRuning) return;
                    _ThisPage.Page.Horn.Data.IsRuning = true;

                    var data = _ThisPage.Page.Horn.Data.Arr[0];
                    _ThisPage.Page.Horn.Data.Arr.splice(0, 1);

                    $('#J_RoomHorn_UserName').text(data.RoomUserInfo.NickName);
                    $('#J_RoomHorn_AnchorName').text(data.RoomAnchorInfo.NickName);
                    $('#J_RoomHorn_UserName, #J_RoomHorn_AnchorName').attr('href', '/room/' + data.RoomAnchorInfo.RoomID);
                    $('#J_RoomHorn_Text').html(_ThisPage.Page.Chat.FaceEmo.FaceEscape(data.RoomUserInfo, data.HornMessage));
                    $('#J_RoomHorn').css({"opacity": 0, 'left': -100}).show();
                    $("#J_RoomHorn").animate({"opacity": 1, 'left': 10}, 300);
                    $('#J_RoomHorn').css({cursor: 'pointer'});
                    $('#J_RoomHorn').off('click');
                    $('#J_RoomHorn').on('click', function (e) {
                        $('#J_RoomHorn_AnchorName')[0].click();
                    });

                    _ThisPage.Page.Horn.Data.TempTimeOut = setTimeout(function () {
                        $("#J_RoomHorn").animate({"opacity": 0, 'left': 100}, 300, function () {
                            $('#J_RoomHorn').hide();
                            _ThisPage.Page.Horn.Data.IsRuning = false;
                            _ThisPage.Page.Horn._ShowEffect();
                        });
                    }, 1000 * _ThisPage.Page.Horn.Data.DurationTime);
                },
                //更新包裹喇叭数量
                UpdatePackage: function () {
                    if ($.CommonMainRoom.UserPackage && $.CommonMainRoom.UserPackage.length > 0) {
                        var ObjData = _.filter($.CommonMainRoom.UserPackage, {Item_ID: "SERVER"});
                        if (ObjData.length > 0 && ObjData[0].Num != undefined && ObjData.length > 0 && ObjData[0].Num > 0) {
                            $("#J_TalkHornNum").show();
                            $("#J_TalkHornNum").text(ObjData[0].Num);
                        } else {
                            $("#J_TalkHornNum").hide();
                        }
                    }
                }
            },
            /**
             * 暴奖
             */
            PondBroadcast: function (data) {
                Log.Out("PondBroadcast ===> ", data);
                if (!data.Burst) return;
                var html = "";
                for (var i = 0; i < data.BurstList.length; i++) {
                    var o = data.BurstList[i];
                    _ThisPage.Page.Chat.GiftAwards(o);
                }
                // $("#J_Chatlistinfo").append(html);
                // _ThisPage.Page.Chat.ChatScrollToBottom();
            },
            /**
             * 房间 机器人
             */
            RobotManage: {
                Data: {
                    NickNameArr: [] //机器人昵称列表
                },
                //初始化
                Init: function () {
                    var UserCount = 0;
                    if($.CommonMainRoom.RoomInfo.Live){
                        var MaxUserCount = _ThisPage.Page.CommonData.GetRandom(9900, 10500);//总人数
                        var AnchorCount = _ThisPage.Page.CommonData.GetRandom(250, 300);//房间主播1:300机器人
                        for (var i = 0; i < _ThisPage.Page.UserList.Data.ListArr.length; i++) {
                            var user = _ThisPage.Page.UserList.Data.ListArr[i];
                            if (user.RoomAnchor) {
                                UserCount += AnchorCount;
                            }else{
                                UserCount += (UserCount >= MaxUserCount) ? 0 : 300;//第个用户算300个机器人，>=MaxUserCount，不添加。
                            }
                        }
                        _ThisPage.Page.RobotManage.AddRobot();
                    }
                    return UserCount;
                },
                AddRobot:function () {
                    //添加虚拟人名
                    for(var i=0; i<50; i++){
                        var UserInfo = {
                            NickName:_ThisPage.Page.RobotManage.Data.NickNameArr[i],
                            IsAnchor:false,
                            IsRobot:true,
                            RoomAdmin:false,
                            RoomAnchor:false,
                            Guest:false,
                            RoomID:$.CommonMainRoom.RoomInfo.RoomID,
                            Level:0,
                            User_ID:999999+i
                        };
                        _ThisPage.Page.UserList.Data.CurrListUserCount++;
                        _ThisPage.Page.UserList.AddUserItem(UserInfo);
                    }
                },
                //加载昵称列表
                LoadNicknameFile: function (filePath) {
                    $.get(filePath, {}, function (data) {
                        _ThisPage.Page.RobotManage.Data.NickNameArr = data.split("\n");
                        _ThisPage.Page.RobotManage.Data.NickNameArr.sort(function () {
                            return 0.5 - Math.random();
                        });
                    }, "text");
                }
            },
            /**
             * 任务列表
             */
            TaskList: {
                //初始化
                Init: function () {
                    //展开任务列表
                    var _This = this;
                    var _ThisState = null;

                    $('[data-task="task"]').on('click', function (event) {
                        event.preventDefault();
                        /* Act on the event */
                        if (!$.CommonMain.LoginCheck()) {
                            return;
                        }
                        _This.LoadTaskList();
                        var elem = $('#J_ModalTaskBox');
                        var _eThis =$(this);
                        dialog({
                            align: 'left',
                            title: '任务',
                            content: elem,
                            id: 'ID_Modal_10005',
                            padding: '0',
                        }).show(_eThis[0]);
                    });

                    //切换任务列表

                    $("#J_TaskTab_all").on("click", "a", function () {
                        var index = $(this).index();
                        $(this).addClass("active").siblings().removeClass("active");
                        $("#J_TaskConts_all .task-cont").eq(index).addClass("active").siblings(".task-cont").removeClass("active");
                    })
                },
                //加载任务列表
                LoadTaskList: function () {
                    $.ajax({
                        url: '/ajax/user.user-task.list',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            Mode: null, //任务模式 null:所有 DAY WEEK MONTH YEAR(多个,号分隔)
                            Status: null //任务状态 null:所有 0:已领取 1:执行中 2:已完成(多个,号分隔) 3:已过期
                        },
                        success: function (data) {
                            Log.Out("任务列表，结果：", data);
                            if (data.flag !== 0) {
                                _ThisPage.Page.CommonUitls.Tip(data.msg);
                                return;
                            }
                            _ThisPage.Page.TaskList.ShowList(data.data);
                        }
                    });
                },
                //显示列表
                ShowList: function (data) {
                    var _Item = '', _ItemOk = '', _Status = '', _StatusClass = '', Task_Reward, _Task_Num = 0;
                    data.forEach(function (value) {
                        if (value.Status == 0) {
                            _Status = "已领取";
                            _StatusClass = 'finish-btn';
                        } else if (value.Status == 1) {
                            _Status = "待完成";
                            _StatusClass = 'ready-btn';
                        } else if (value.Status == 2) {
                            _Status = "领取";
                            _StatusClass = 'execute-btn';
                        } else if (value.Status == 3) {
                            _Status = "已过期";
                            _StatusClass = 'fail-btn';
                        }

                        if (typeof value.Task_Reward == "string") {
                            Task_Reward = JSON.parse(value.Task_Reward)[0].Text;
                        } else {
                            Task_Reward = value.Task_Reward[0].Text
                        }
                        if (value.Status == 0) {
                            return;
                        }
                        if (value.Status == 1) {
                            _Item += '<dl>' +
                                '<dt>' + value.Task_Name + '</dt>' +
                                '<dd>' +
                                '<span>' + Task_Reward + '</span>' +
                                '<a href="javascript:;" class="' + _StatusClass + '" data-task-id="' + value.Task_ID + '" data-task-date="' + value.Task_Date + '" data-task-mode="' + value.Task_Mode + '">' + _Status + '</a>' +
                                '</dd>' +
                                '</dl>';
                        }
                        if (value.Status == 2) {
                            _Task_Num++;
                            _ItemOk += '<dl>' +
                                '<dt>' + value.Task_Name + '</dt>' +
                                '<dd>' +
                                '<span>' + Task_Reward + '</span>' +
                                '<a href="javascript:;" class="' + _StatusClass + '" data-task-id="' + value.Task_ID + '" data-task-date="' + value.Task_Date + '" data-task-mode="' + value.Task_Mode + '">' + _Status + '</a>' +
                                '</dd>' +
                                '</dl>';
                        }
                    });
                    $("#J_TaskFinishNum").text(_Task_Num);
                    $("#J_TaskCont_all").html(_Item);
                    $("#J_TaskCont_finish").html(_ItemOk);

                    //点击领取任务奖励
                    $("#J_TaskCont_all,#J_TaskCont_finish").on('click', "dd >a ", function (event) {
                        event.preventDefault();
                        _ThisState = $(this);
                        var Task = {};
                        Task.Task_ID = $(this).data('task-id');
                        Task.Task_Mode = $(this).data('task-mode');
                        Task.Task_Date = $(this).data('task-date');
                        $.ajax({
                            url: '/ajax/user.user-info.checkbindphone',
                            type: 'post',
                            dataType: 'json',
                            success: function (data) {
                                if (data.Phone) {
                                    _ThisPage.Page.TaskList.TaskReceive(Task.Task_ID, Task.Task_Mode, Task.Task_Date);
                                } else {
                                    _ThisPage.Page.CommonUitls.Tip("请先<a href='/member/user/security' target='_blank'>绑定手机</a>,才可以领取任务奖励哦~", {Autoclosed: false});
                                    return;
                                }
                            }
                        });
                    });
                },
                //任务领取
                TaskReceive: function (Task_ID, Task_Mode, Task_Date) {
                    $.ajax({
                        url: '/ajax/user.user-task.update-receive',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            ID: Task_ID,// null 任务ID(任务列表里返回)
                            Mode: Task_Mode, //任务模式(任务列表里返回)
                            Date: Task_Date //任务时间(任务列表里返回)
                        },
                        success: function (data) {
                            Log.Out("领取任务，结果：", data);
                            // if (data.flag !== 0) {
                            //     _ThisPage.Page.CommonUitls.Tip(data.msg);
                            //     return;
                            // }
                            if (data.flag === 0) {
                                $("#J_TaskFinishNum").text($("#J_TaskFinishNum").text() - 1);
                                _ThisState.removeClass("execute-btn").addClass("finish-btn").text("已领取")
                            }
                        }
                    });
                }
            },
            /**
             * 举报
             */
            Report: {
                Init: function () {
                    $('.head-tool-report').on('click', function () {
                        if (confirm("是 / 否 举报该直播间【" + $.CommonMainRoom.RoomAnchorInfo.NickName + ", 房号：" + $.CommonMainRoom.RoomInfo.RoomID + "】？")) {
                            alert('举报成功！');
                        }
                    });

                    // $("#J_ReportRoomAnchor").off('click');
                    // $("#J_ReportRoomAnchor").on("click", function () {
                    //     if (!$.CommonMain.LoginCheck()) {
                    //         return;
                    //     }
                    //     if ($("#J_ModalreportBox").length < 1) {
                    //         $.ajax({
                    //             url: '/report/anchor/',
                    //             type: 'get',
                    //             dataType: 'html',
                    //             success: function (data) {
                    //                 $("#J_ReportContainer").html(data);
                    //             }
                    //         });
                    //     }
                    //
                    //     var elem_100018 = $('#J_ReportContainer');
                    //     var dialog_100018;
                    //     dialog_100018 = dialog({
                    //         title: '举报艺人',
                    //         content: elem_100018,
                    //         id: 'ID_Modal_100018',
                    //         padding: '0',
                    //         width: '520px'
                    //     }).show();
                    // });
                }
            },
            /**
             * 游戏
             */
            Game: {
                Init:function () {
                    _ThisPage.Page.Game.Lottery.Init();
                    _ThisPage.Page.Game.PoundEgg.Init();
                },
                //转盘游戏
                Lottery:{
                    Data:{
                        RotateState: false
                    },
                    Init:function () {
                        $('[data-game="game-lottery"]').off("click");
                        $('[data-game="game-lottery"]').on("click", function () {
                            if ($("#J_GameRotateC").length > 0) {
                                return;
                            }
                            $.ajax({
                                url: '/activity/game/lottery/',
                                type: 'get',
                                dataType: 'html',
                                success: function (data) {
                                    $('[data-game-switch="true"]').remove();
                                    $("body").append(data);
                                    _ThisPage.Page.Game.Lottery.Data.RotateState = true;
                                }
                            });
                        })
                    }
                },
                //砸蛋游戏
                PoundEgg:{
                    Data:{},
                    Init:function () {
                        $('[data-game="game-goldegg"]').off('click');
                        $('[data-game="game-goldegg"]').on('click', function () {
                            $('[data-game-switch="true"]').remove();
                            var left = $('.xd-container').hasClass('collapse-state') ? 71 : 255;//是否 折叠状态位置
                            var html = '<div id="J_GoldEgg_DIV" data-game-switch="true" style="position: absolute;left:'+left+'px;bottom:120px;width: 350px;height: 460px;z-index:201;">' +
                                '<object id="J_GoldEggSwf" width="100%" height="100%" align="middle" data="/player/PoundEgg.swf" class="main-player-swf" type="application/x-shockwave-flash">' +
                                '<param value="high" name="quality">' +
                                '<param value="true" name="play">' +
                                '<param value="false" name="loop">' +
                                '<param value="transparent" name="wmode">' +
                                '<param value="noscale" name="scale">' +
                                '<param value="false" name="menu">' +
                                '<param value="false" name="devicefont">' +
                                '<param value="" name="salign">' +
                                '<param value="always" name="allowscriptaccess">' +
                                '<param value="true" name="allowfullscreen">' +
                                '<param name="bgColor" value="#222">' +
                                '<param value="" name="flashvars">' +
                                '</object>' +
                                '</div>';
                            $("body").append(html);
                        });
                    },
                    Result:function (data, isSendDataToSwf) {
                        Log.Out('PoundEgg Data Result', data);

                        if(isSendDataToSwf){
                            data.type = "PoundEgg_Result";
                            $('#J_GoldEggSwf')[0].onJsToAs(data);
                        }

                        if(!isSendDataToSwf
                            && data.PoundEggWinningList
                            && data.PoundEggWinningList.length >0
                            && data.PoundEggWinningList[0].Inform
                            && (data.PoundEggWinningList[0].Inform == "ROOM" || data.PoundEggWinningList[0].Inform == "SERVER")){
                            //中奖消息 显示到聊天区
                            _ThisPage.Page.Chat.GiftLuckDraw(data);
                        }

                    }
                }
            },
            ReSize: {
                Init: function () {
                    _ThisPage.Page.ReSize.Change();
                    $(window).resize(function () {
                        _ThisPage.Page.ReSize.Change();
                    });
                },
                Change: function () {
                    var _PW = $(window).width();
                    $("#J_ToolBarTask").show();
                    if(_PW>1366){
                        _ThisPage.Page.ReSize.Expand();
                    }else{
                        _ThisPage.Page.ReSize.Collapse();
                    }
                },
                //折叠
                Collapse:function(){
                    $('body').addClass('xd-container collapse-state');
                    $('.xd-container').removeClass('expand-state').addClass('collapse-state');
                    $(".sidebar-container").removeClass("sidebar-expand").addClass('sidebar-collapsed');
                    $('#J_GoldEgg_DIV').css('left', '71px');
                },
                //展开
                Expand:function(){
                    $('body').addClass('xd-container expand-state');
                    $('.xd-container').removeClass('collapse-state').addClass('expand-state');
                    $(".sidebar-container").removeClass("sidebar-collapsed").addClass('sidebar-expand');
                    $('#J_GoldEgg_DIV').css('left', '255px');
                }
            },
            WinResize:function(){
                $(".sidebar-toggle-btn").on('click',function(event) {
                    event.preventDefault();
                    var _PW = $(window).width();
                    if($('.xd-container').hasClass('collapse-state')){
                        _ThisPage.Page.ReSize.Expand();
                        if(_PW>1366){
                            $("#J_ToolBarTask").show();
                        }else{
                            $("#J_ToolBarTask").hide();
                        }
                    }else{
                        _ThisPage.Page.ReSize.Collapse();
                        $("#J_ToolBarTask").show();
                    }
                });
            }
        }
    };
    var _Socket = {
        Init:function () {
            $.CommonMainRoom.fnInit({
                SocketURL: _VirtualPath.Socket + 'room',
                RoomID: _PageData.RoomID,
                //
                onConnect: function () {
                    Log.Out("onConnect");
                },
                onJoin: function (data) {
                    Log.Out("onJoin", data);
                    _ThisPage.Page.JoinComplete(data);
                },
                onJoinBroadcast: function (data) {
                    Log.Out("onJoinBroadcast", data);
                    _ThisPage.Page.Chat.RoomEnterNewUserNotify(data);
                },
                onOutBroadcast: function (data) {
                    Log.Out("onOutBroadcast", data);
                },
                onDisconnect: function () {
                    Log.Out('onDisconnect');
                    _ThisPage.Page.Video.LiveEnd();
                    // window.document.location.reload();
                },
                onUserList: function (data) {
                    Log.Out("onUserList", data);
                    _ThisPage.Page.UserList.Result(data);
                },
                onUserLevelBroadcast: function (data) {
                    Log.Out("onUserLevelBroadcast", data);
                },
                onAdminList: function (data) {
                    Log.Out("onAdminList", data);
                    _ThisPage.Page.UserList.Admin.Result(data);
                },
                onAdminListBroadcast: function (data) {
                    Log.Out("onAdminListBroadcast", data);
                    _ThisPage.Page.UserList.Admin.Result(data);
                },
                onLive: function (data) {
                    Log.Out("onLive", data);
                    //艺人推流 修改前
                    // _ThisPage.Flash.PublishVideo(data);
                    //艺人拉流 修改后
                    _ThisPage.Flash.PlayVideo(data.RoomInfo);
                    _ThisPage.Page.Video.GetRecommend(false);
                    _ThisPage.Page.Video.Playing(true);
                    if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                        $('.player-live-btn').show();
                        $("#J_LiveStartBtn").hide();
                        $("#J_LiveEndBtn").show();
                        // _ThisPage.Page.RobotManage.Init();
                    }
                },
                onLiveBroadcast: function (data) {
                    Log.Out("onLiveBroadcast", data);
                    if (data.Type == "LiveEnd-BlockSet" || data.Type == "LiveEnd-WarningSet-Block") {
                        _ThisPage.Flash.EndLive();
                        _ThisPage.Page.Video.GetRecommend(true);
                        _ThisPage.Page.Video.Playing(false);
                        alert("此房间已被冻结！");
                        window.document.location = _VirtualPath.Main;
                        return;
                    }
                    if (data.Type == "Live") {
                        if (data.RoomInfo.Live) {
                            // _ThisPage.Page.RobotManage.Init();
                            _ThisPage.Flash.PlayVideo(data.RoomInfo);
                            _ThisPage.Page.Video.GetRecommend(false);
                            _ThisPage.Page.Video.Playing(true);
                            if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                                $('.player-live-btn').show();
                                $("#J_LiveStartBtn").hide();
                                $("#J_LiveEndBtn").show();
                            }
                        } else {
                            _ThisPage.Flash.EndLive();
                            _ThisPage.Page.Video.GetRecommend(true);
                            _ThisPage.Page.Video.Playing(false);
                            if ($.CommonMainRoom.RoomUserInfo.RoomAnchor) {
                                $('.player-live-btn').show();
                                $("#J_LiveStartBtn").show();
                                $("#J_LiveEndBtn").hide();
                            }
                        }
                        return;
                    }
                    if (data.Type == "LiveEnd" ||
                        data.Type == "LiveEnd-Disconnect" ||
                        data.Type == "LiveEnd-WarningSet-End") {
                        _ThisPage.Page.Video.LiveEnd();
                        return;
                    }
                },
                onRunwayBroadcast: function (data) {
                    Log.Out("onRunwayBroadcast", data);
                    _ThisPage.Page.Runway.AddRunway(data);
                },
                onGuardian: function (data) {
                    Log.Out("onGuardian", data);
                    _ThisPage.Page.Guardian.BuyResult(data);
                    if ($("#J_EmoGuardPanel").length > 0) $("#J_EmoGuardPanel").remove();//删除守护表情 购买按钮
                },
                onGuardianBroadcast: function (data) {
                    Log.Out("onGuardianBroadcast", data);
                    _ThisPage.Page.Guardian.BuyResult(data);
                },
                onGift: function (data) {
                    Log.Out("onGift", data);
                    _ThisPage.Page.Gift.Data.sending = false;
                    _ThisPage.Page.Gift.RoomGiftGiveResult(data);
                    _ThisPage.Page.Gift.ShowGiftBtnAnimation();
                },
                onGiftBroadcast: function (data) {
                    Log.Out("onGiftBroadcast", data);
                    _ThisPage.Page.Gift.RoomGiftGiveResult(data);
                },
                onGiftHeadlineBroadcast: function (data) {
                    Log.Out('onGiftHeadlineBroadcast', data);
                },
                onHorn: function (data) {
                    Log.Out("onHorn", data);
                    if ("ROOM" === data.HornInfo.Mode) {
                        _ThisPage.Page.FlyScreen.ShowEffect(data);
                    }
                },
                onHornBroadcast: function (data) {
                    Log.Out("onHornBroadcast", data);
                    if ("ROOM" === data.HornInfo.Mode) {
                        _ThisPage.Page.FlyScreen.ShowEffect(data);
                    } else if ("SERVER" === data.HornInfo.Mode) {
                        _ThisPage.Page.Horn.ShowEffect(data);
                    }
                },
                onPomeloGet: function (data) {
                    Log.Out("onPomeloGet", data);
                    _ThisPage.Page.PomeloUtil.UpdateSelfPomeloNum(data);
                },
                onPomeloPresent: function (data) {
                    Log.Out("onPomeloPresent", data);
                    _ThisPage.Page.PomeloUtil.ShowPomeloHistoryList(data);
                },
                onPomeloPresentBroadcast: function (data) {
                    Log.Out("onPomeloPresentBroadcast", data);
                    _ThisPage.Page.PomeloUtil.ShowPomeloHistoryList(data);
                },
                onMessage: function (data) {
                    Log.Out("onMessage", data);
                    _ThisPage.Page.Chat.Data.MsgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);//以服务器返回的用户数据为准。
                    _ThisPage.Page.Chat.ChatShowMsg(_ThisPage.Page.Chat.Data.MsgObj);
                },
                onMessageBroadcast: function (data) {
                    Log.Out("onMessageBroadcast", data);
                    _ThisPage.Page.Chat.ChatServerMsgReceive(data);
                },
                onAdminSet: function (data) {
                    Log.Out("onAdminSet", data);
                    _ThisPage.Page.CommonUitls.UserRoleTip(data, "Admin");
                },
                onAdminSetBroadcast: function (data) {
                    Log.Out("onAdminSetBroadcast", data);
                    _ThisPage.Page.CommonUitls.UserRoleTip(data, "Admin");
                },
                onBlackSet: function (data) {
                    Log.Out("onBlackSet", data);
                    _ThisPage.Page.CommonUitls.UserRoleTip(data, "Black");
                },
                onBlackSetBroadcast: function (data) {
                    Log.Out("onBlackSetBroadcast", data);
                    _ThisPage.Page.CommonUitls.UserRoleTip(data, "Black");
                },
                onBlockSet: function (data) {
                    Log.Out("onBlockSet", data);
                },
                onWarningSet:function (data) {
                    Log.Out("onWarningSet===>", data);
                    $.CommonMain.Modal_Tip("操作成功！", {Timeout: 2000});
                },
                onWarningSetBroadcast:function (data) {
                    Log.Out("onWarningSetBroadcast", data);
                    _ThisPage.Page.Chat.WarningSet(data);
                },
                onLottery: function (data) {
                    Log.Out("onLottery", data);
                    if (_ThisPage.Page.Game.Lottery.Data.RotateState) {
                        GameLottery.GameLotteryResult("onLottery", data);
                        GameLottery.GameLotteryResultShow("onRoomLottery", data);
                    }
                },
                onPoundEgg: function (data) {
                    Log.Out("onPoundEgg", data);
                    _ThisPage.Page.Game.PoundEgg.Result(data, true);
                },
                onPoundEggBroadcast: function (data) {
                    Log.Out("onPoundEggBroadcast", data);
                    _ThisPage.Page.Game.PoundEgg.Result(data, false);
                },
                onRoomLottery: function (data) {
                    Log.Out("onRoomLottery", data);
                    if (_ThisPage.Page.Game.Lottery.Data.RotateState) {
                        GameLottery.GameLotteryResultShow("onRoomLottery", data);
                    }
                },
                onServerLottery: function (data) {
                    Log.Out("onServerLottery", data);
                    if (_ThisPage.Page.Game.Lottery.Data.RotateState) {
                        if (data.RoomUserInfo.User_ID != $.CommonMainRoom.RoomUserInfo.User_ID) {
                            GameLottery.GameLotteryResultShow("onServerLottery", data);
                        }
                    }
                },

                fnRoomInfo: function (data) {
                    // Log.Out("---RoomData---", [
                    //     {"$.CommonMainRoom.RoomInfo":$.CommonMainRoom.RoomInfo},
                    //     {"$.CommonMainRoom.RoomAnchorInfo":$.CommonMainRoom.RoomAnchorInfo},
                    //     {"$.CommonMainRoom.RoomUserInfo":$.CommonMainRoom.RoomUserInfo}]);
                    Log.Out("fnRoomInfo", data);
                    _ThisPage.Page.Room.UpdateInfo(data);
                },
                fnRoomUserInfo: function (data) {
                    Log.Out("fnRoomUserInfo", data);
                    _ThisPage.Page.Self.UpdateInfo(data);
                },
                fnRoomAnchorInfo: function (data) {
                    Log.Out("fnRoomAnchorInfo", data);
                    if (data.RoomID != _PageData.RoomID) return; //不是本房间的艺人信息，就拦截，不要更新。
                    _ThisPage.Page.Anchor.UpdateInfo(data);
                },
                fnRoomGiftPond: function (data) {
                    Log.Out("fnRoomGiftPond", data);
                    _ThisPage.Page.PondBroadcast(data);
                },
                fnRoomGuardian: function (data) {
                    Log.Out("fnRoomGuardian", data);
                    _ThisPage.Page.Guardian.UpdateNotify(data);
                },
                fnGiftFloat: function(data){
                    Log.Out("fnGiftFloat", data);
                    //_ThisPage.Page.GiftBig.Update(data);
                },
                fnGiftHeadline: function (data) {
                    Log.Out('fnGiftHeadline', data);
                    _ThisPage.Page.GiftHeadline.UpdateGiftHeadline(data);
                },
                fnBlackJoin: function (data) {
                    _ThisPage.Flash.EndLive();
                    alert(data);
                    window.document.location = _VirtualPath.Main;
                },
                fnErrorNotEnough: function (data) {
                    Log.Out("fnErrorNotEnough", data);
                    _ThisPage.Page.Gift.Data.sending = false;
                    _ThisPage.Page.CommonUitls.PayBoxPanel.Show();
                    if (GameLottery) GameLottery.GameLottery_Notice(data);
                },
                fnErrorOther: function (data) {
                    Log.Out("fnErrorOther", data);
                    _ThisPage.Page.Gift.Data.sending = false;
                    // _ThisPage.Page.CommonUitls.Tip("Error " + data.message + "(" + data.flag + ")");
                    $.KOC.Tips.Open('Error', data.message + "(" + data.flag + ")", {Timeout: 2000});

                },
                fnUserPackage: function (data) {
                    Log.Out("fnUserPackage", data);
                    _ThisPage.Page.Gift.UpdateUserPackage(data);
                    _ThisPage.Page.FlyScreen.UpdatePackage();
                    _ThisPage.Page.Horn.UpdatePackage();
                }
            });
        }
    };
    _ThisPage.Page.Init();
});